Skip to content

Commit f91d859

Browse files
committed
fix(test): preserve failed shard diagnostics
1 parent 1daea4c commit f91d859

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎scripts/test-projects.mjs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ async function main() {
369369
}
370370
releaseLockOnce();
371371
if (parallelExitCode !== 0) {
372-
process.exit(parallelExitCode);
372+
process.exitCode = parallelExitCode;
373373
}
374374
return;
375375
}
@@ -390,7 +390,8 @@ async function main() {
390390
if (spec.continueOnFailure !== true) {
391391
printTestSummary("failed", timings.length, performance.now() - suiteStartedAt);
392392
releaseLockOnce();
393-
process.exit(result.code);
393+
process.exitCode = result.code;
394+
return;
394395
}
395396
}
396397
}
@@ -403,7 +404,7 @@ async function main() {
403404

404405
releaseLockOnce();
405406
if (exitCode !== 0) {
406-
process.exit(exitCode);
407+
process.exitCode = exitCode;
407408
}
408409
}
409410

@@ -418,6 +419,6 @@ main().catch(
418419
/** @param {unknown} error */ (error) => {
419420
releaseLockOnce();
420421
console.error(error);
421-
process.exit(1);
422+
process.exitCode = 1;
422423
},
423424
);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,6 +3286,12 @@ describe("scripts/test-projects changed-target routing", () => {
32863286
expect(result.stderr).not.toContain("[test] starting");
32873287
});
32883288

3289+
it("lets buffered failure diagnostics drain before the dispatcher exits", () => {
3290+
const source = fs.readFileSync("scripts/test-projects.mjs", "utf8");
3291+
3292+
expect(source).not.toContain("process.exit(");
3293+
});
3294+
32893295
it("allows explicit split Vitest config targets without treating them as unmatched tests", () => {
32903296
expect(
32913297
findUnmatchedExplicitTestTargets(

0 commit comments

Comments
 (0)