diff --git a/scripts/test-projects.test-support.mjs b/scripts/test-projects.test-support.mjs index 6d4f212425d..28172f8bece 100644 --- a/scripts/test-projects.test-support.mjs +++ b/scripts/test-projects.test-support.mjs @@ -620,7 +620,10 @@ export function buildFullSuiteVitestRunPlans(args, cwd = process.cwd()) { }, ]; } - const expandToProjectConfigs = process.env.OPENCLAW_TEST_PROJECTS_LEAF_SHARDS === "1"; + const parallelShardCount = Number.parseInt(process.env.OPENCLAW_TEST_PROJECTS_PARALLEL ?? "", 10); + const expandToProjectConfigs = + process.env.OPENCLAW_TEST_PROJECTS_LEAF_SHARDS === "1" || + (Number.isFinite(parallelShardCount) && parallelShardCount > 1); return fullSuiteVitestShards.flatMap((shard) => { if ( process.env.OPENCLAW_TEST_SKIP_FULL_EXTENSIONS_SHARD === "1" && diff --git a/test/scripts/test-projects.test.ts b/test/scripts/test-projects.test.ts index 5a9e7bdd52a..fffab56d4cd 100644 --- a/test/scripts/test-projects.test.ts +++ b/test/scripts/test-projects.test.ts @@ -337,6 +337,30 @@ describe("scripts/test-projects full-suite sharding", () => { } }); + it("expands full-suite shards before running them in parallel", () => { + const previousLeafShards = process.env.OPENCLAW_TEST_PROJECTS_LEAF_SHARDS; + const previousParallel = process.env.OPENCLAW_TEST_PROJECTS_PARALLEL; + delete process.env.OPENCLAW_TEST_PROJECTS_LEAF_SHARDS; + process.env.OPENCLAW_TEST_PROJECTS_PARALLEL = "6"; + try { + const configs = buildFullSuiteVitestRunPlans([], process.cwd()).map((plan) => plan.config); + + expect(configs).toContain("vitest.extension-telegram.config.ts"); + expect(configs).not.toContain("vitest.full-extensions.config.ts"); + } finally { + if (previousLeafShards === undefined) { + delete process.env.OPENCLAW_TEST_PROJECTS_LEAF_SHARDS; + } else { + process.env.OPENCLAW_TEST_PROJECTS_LEAF_SHARDS = previousLeafShards; + } + if (previousParallel === undefined) { + delete process.env.OPENCLAW_TEST_PROJECTS_PARALLEL; + } else { + process.env.OPENCLAW_TEST_PROJECTS_PARALLEL = previousParallel; + } + } + }); + it("keeps untargeted watch mode on the native root config", () => { expect(buildFullSuiteVitestRunPlans(["--watch"], process.cwd())).toEqual([ {