From a29b501ec9b761088481d4238af4e78635686f3f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 6 Apr 2026 22:08:58 +0100 Subject: [PATCH] perf(test): fix unit shard config regressions --- src/utils.test.ts | 4 ++-- test/vitest-unit-config.test.ts | 12 ++++++++++++ vitest.shared.config.ts | 4 ++++ vitest.unit.config.ts | 3 ++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/utils.test.ts b/src/utils.test.ts index 87940bfdc77..1daa84408c4 100644 --- a/src/utils.test.ts +++ b/src/utils.test.ts @@ -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); diff --git a/test/vitest-unit-config.test.ts b/test/vitest-unit-config.test.ts index ae857535e7c..d0b1fad07a7 100644 --- a/test/vitest-unit-config.test.ts +++ b/test/vitest-unit-config.test.ts @@ -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/**"]), + ); + }); }); diff --git a/vitest.shared.config.ts b/vitest.shared.config.ts index 256f06183c6..ce82f4d56b0 100644 --- a/vitest.shared.config.ts +++ b/vitest.shared.config.ts @@ -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"), diff --git a/vitest.unit.config.ts b/vitest.unit.config.ts index 26ea01fbc92..2cf70411714 100644 --- a/vitest.unit.config.ts +++ b/vitest.unit.config.ts @@ -48,7 +48,8 @@ export function createUnitVitestConfigWithOptions( exclude: [ ...new Set([ ...exclude, - ...(options.extraExcludePatterns ?? unitTestAdditionalExcludePatterns), + ...unitTestAdditionalExcludePatterns, + ...(options.extraExcludePatterns ?? []), ...loadExtraExcludePatternsFromEnv(env), ]), ],