Skip to content

Commit a12a98e

Browse files
committed
test(matrix): align full-suite chunk expectations
1 parent 671d384 commit a12a98e

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

‎test/scripts/test-projects.test.ts‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
import { fullSuiteVitestShards } from "../vitest/vitest.test-shards.mjs";
4545

4646
const normalizeRepoPath = toRepoPath;
47+
const MATRIX_TEST_PROCESS_FILE_LIMIT = 40;
4748

4849
type VitestTestConfig = {
4950
dir?: string;
@@ -74,6 +75,11 @@ function findVitestConfigFactory(mod: Record<string, unknown>): VitestConfigFact
7475
return null;
7576
}
7677

78+
function expectedMatrixTestProcessCount() {
79+
const testFileCount = listExtensionTestFilesForRoots(["extensions/matrix"]).length;
80+
return Math.max(1, Math.ceil(testFileCount / MATRIX_TEST_PROCESS_FILE_LIMIT));
81+
}
82+
7783
async function loadRawVitestConfig(configPath: string): Promise<VitestConfig> {
7884
const previousArgv = process.argv;
7985
const previousIncludeFile = process.env.OPENCLAW_VITEST_INCLUDE_FILE;
@@ -3235,8 +3241,12 @@ describe("scripts/test-projects changed-target routing", () => {
32353241
watchMode: false,
32363242
})),
32373243
);
3238-
expect(matrixPlans).toHaveLength(3);
3239-
expect(matrixPlans.every((plan) => (plan.includePatterns?.length ?? 0) <= 40)).toBe(true);
3244+
expect(matrixPlans).toHaveLength(expectedMatrixTestProcessCount());
3245+
expect(
3246+
matrixPlans.every(
3247+
(plan) => (plan.includePatterns?.length ?? 0) <= MATRIX_TEST_PROCESS_FILE_LIMIT,
3248+
),
3249+
).toBe(true);
32403250
expect(matrixPlans.flatMap((plan) => plan.includePatterns ?? [])).toEqual(
32413251
listExtensionTestFilesForRoots(["extensions/matrix"]),
32423252
);
@@ -3246,11 +3256,13 @@ describe("scripts/test-projects changed-target routing", () => {
32463256
it("bounds an explicit Matrix directory target across process lifetimes", () => {
32473257
const plans = buildVitestRunPlans(["extensions/matrix"], process.cwd());
32483258

3249-
expect(plans).toHaveLength(3);
3259+
expect(plans).toHaveLength(expectedMatrixTestProcessCount());
32503260
expect(
32513261
plans.every((plan) => plan.config === "test/vitest/vitest.extension-matrix.config.ts"),
32523262
).toBe(true);
3253-
expect(plans.every((plan) => (plan.includePatterns?.length ?? 0) <= 40)).toBe(true);
3263+
expect(
3264+
plans.every((plan) => (plan.includePatterns?.length ?? 0) <= MATRIX_TEST_PROCESS_FILE_LIMIT),
3265+
).toBe(true);
32543266
expect(plans.flatMap((plan) => plan.includePatterns ?? [])).toEqual(
32553267
listExtensionTestFilesForRoots(["extensions/matrix"]),
32563268
);
@@ -3264,7 +3276,10 @@ describe("scripts/test-projects changed-target routing", () => {
32643276

32653277
const plans = buildVitestRunPlans(["extensions/matrix", testFile], process.cwd());
32663278

3267-
expect(plans).toHaveLength(3);
3279+
expect(plans).toHaveLength(expectedMatrixTestProcessCount());
3280+
expect(
3281+
plans.every((plan) => (plan.includePatterns?.length ?? 0) <= MATRIX_TEST_PROCESS_FILE_LIMIT),
3282+
).toBe(true);
32683283
expect(plans.flatMap((plan) => plan.includePatterns ?? [])).toEqual(
32693284
listExtensionTestFilesForRoots(["extensions/matrix"]),
32703285
);
@@ -4652,8 +4667,10 @@ describe("scripts/test-projects full-suite sharding", () => {
46524667
expect(toolingTargets).not.toContain("test/scripts/docker-build-helper.test.ts");
46534668
expect(toolingTargets).not.toContain("test/scripts/openclaw-e2e-instance.test.ts");
46544669
const matrixTargets = matrixPlans.flatMap((plan) => plan.forwardedArgs);
4655-
expect(matrixPlans).toHaveLength(3);
4656-
expect(matrixPlans.every((plan) => plan.forwardedArgs.length <= 40)).toBe(true);
4670+
expect(matrixPlans).toHaveLength(expectedMatrixTestProcessCount());
4671+
expect(
4672+
matrixPlans.every((plan) => plan.forwardedArgs.length <= MATRIX_TEST_PROCESS_FILE_LIMIT),
4673+
).toBe(true);
46574674
expect(matrixTargets).toEqual(listExtensionTestFilesForRoots(["extensions/matrix"]));
46584675
expect(
46594676
plans.filter(

0 commit comments

Comments
 (0)