Skip to content

Commit aead6c1

Browse files
committed
fix(test): route unprofilable pools past the vitest profiling runner
The profiling runner supports only forks/threads pools, but the fork-shutdown fixture sent every scenario except plain/custom through it. vmForks and the custom-opt-in pool died during global setup, so the inner run never wrote its receipt and the fixture crashed with ENOENT instead of a usable failure. Route those scenarios through the plain runner and assert profiling artifacts only for runs the fixture actually profiled; worker-shutdown assertions are unchanged.
1 parent cfa802d commit aead6c1

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎test/fixtures/vitest-fork-shutdown.mjs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,12 @@ it("completes the test before worker shutdown", () => {
252252
});
253253
`,
254254
);
255+
// The profiling runner rejects any pool other than forks/threads
256+
// (scripts/lib/vitest-profiler.mts), so vmForks and custom-pool scenarios must
257+
// run through the plain runner or the inner run dies during global setup.
258+
const profilerSupportsPool = !custom && scenario !== "vmForks";
255259
const args =
256-
scenario === "plain" || scenario === "custom"
260+
scenario === "plain" || !profilerSupportsPool
257261
? [
258262
path.join(repo, "scripts/run-vitest.mjs"),
259263
"run",
@@ -315,6 +319,7 @@ it("completes the test before worker shutdown", () => {
315319
code,
316320
output,
317321
workerStopped,
322+
profiled: profilerSupportsPool && scenario !== "plain",
318323
profiles: counts,
319324
homeRemoved: !fs.existsSync(state.home),
320325
callerPreserved: fs.readFileSync(path.join(root, "home", "caller"), "utf8") === "keep",

‎test/scripts/vitest-fork-shutdown.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ it.each([
6868
);
6969
expect(result.events).toContainEqual({ event: "terminate", signal: "SIGTERM" });
7070
} else if (scenario !== "plain") {
71-
expect(result.profiles.cpu, result.output).toBeGreaterThan(0);
72-
expect(result.profiles.heap, result.output).toBeGreaterThan(0);
71+
// Only runs routed through the profiling runner emit profiles; the fixture
72+
// reports that, since the profiler rejects vmForks and custom pools.
73+
if (result.profiled) {
74+
expect(result.profiles.cpu, result.output).toBeGreaterThan(0);
75+
expect(result.profiles.heap, result.output).toBeGreaterThan(0);
76+
} else {
77+
expect(result.output, result.output).toContain("1 passed");
78+
}
7379
expect(result.events.some((event: { event: string }) => event.event === "terminate")).toBe(
7480
false,
7581
);

0 commit comments

Comments
 (0)