perf(test): fix unit shard config regressions

This commit is contained in:
Peter Steinberger
2026-04-06 22:08:58 +01:00
parent 4ae1599ea5
commit a29b501ec9
4 changed files with 20 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { withTempDir, withTempDirSync } from "./test-helpers/temp-dir.js";
import { withTempDir } from "./test-helpers/temp-dir.js";
import {
ensureDir,
resolveConfigDir,
@@ -34,7 +34,7 @@ describe("sleep", () => {
describe("resolveConfigDir", () => {
it("prefers ~/.openclaw when legacy dir is missing", async () => {
await withTempDirSync({ prefix: "openclaw-config-dir-" }, async (root) => {
await withTempDir({ prefix: "openclaw-config-dir-" }, async (root) => {
const newDir = path.join(root, ".openclaw");
await fs.promises.mkdir(newDir, { recursive: true });
const resolved = resolveConfigDir({} as NodeJS.ProcessEnv, () => root);

View File

@@ -97,4 +97,16 @@ describe("unit vitest config", () => {
"test/setup-openclaw-runtime.ts",
]);
});
it("appends extra exclude patterns instead of replacing the base unit excludes", () => {
const unitConfig = createUnitVitestConfigWithOptions(
{},
{
extraExcludePatterns: ["src/security/**"],
},
);
expect(unitConfig.test?.exclude).toEqual(
expect.arrayContaining(["src/commands/**", "src/config/**", "src/security/**"]),
);
});
});

View File

@@ -189,6 +189,10 @@ export const sharedVitestConfig = {
find: `openclaw/plugin-sdk/${subpath}`,
replacement: path.join(repoRoot, "src", "plugin-sdk", `${subpath}.ts`),
})),
...pluginSdkSubpaths.map((subpath) => ({
find: `@openclaw/plugin-sdk/${subpath}`,
replacement: path.join(repoRoot, "packages", "plugin-sdk", "src", `${subpath}.ts`),
})),
{
find: "openclaw/plugin-sdk",
replacement: path.join(repoRoot, "src", "plugin-sdk", "index.ts"),

View File

@@ -48,7 +48,8 @@ export function createUnitVitestConfigWithOptions(
exclude: [
...new Set([
...exclude,
...(options.extraExcludePatterns ?? unitTestAdditionalExcludePatterns),
...unitTestAdditionalExcludePatterns,
...(options.extraExcludePatterns ?? []),
...loadExtraExcludePatternsFromEnv(env),
]),
],