Skip to content

Commit ea894bb

Browse files
authored
fix(test): preserve failed shard diagnostics (#116289)
1 parent c63fdc6 commit ea894bb

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
@@ -3298,6 +3298,12 @@ describe("scripts/test-projects changed-target routing", () => {
32983298
expect(result.stderr).not.toContain("[test] starting");
32993299
});
33003300

3301+
it("lets buffered failure diagnostics drain before the dispatcher exits", () => {
3302+
const source = fs.readFileSync("scripts/test-projects.mjs", "utf8");
3303+
3304+
expect(source).not.toContain("process.exit(");
3305+
});
3306+
33013307
it("allows explicit split Vitest config targets without treating them as unmatched tests", () => {
33023308
expect(
33033309
findUnmatchedExplicitTestTargets(

0 commit comments

Comments
 (0)