1// @effect-diagnostics nodeBuiltinImport:off - retention assertions need an isolated process with explicit GC.
2import * as NodeChildProcess from "node:child_process";
3import * as NodeURL from "node:url";
4import * as NodeUtil from "node:util";
5import { expect, it } from "vite-plus/test";
6const execFile = NodeUtil.promisify(NodeChildProcess.execFile);
7it.each([false, true])(
8 "a detached cache lookup releases the traced caller snapshot (failure=%s)",
9 async (failure) => {
10 const fixture = NodeURL.fileURLToPath(
11 new URL("./testing/StackRetention.fixture.mjs", import.meta.url),
12 );
13 const { stdout } = await execFile(process.execPath, [
14 "--expose-gc",
15 fixture,
16 ...(failure ? ["failure"] : []),
17 ]);
18 expect(JSON.parse(stdout)).toEqual({
19 retained: false,
20 cachedResult: failure ? "unavailable" : 1,
21 });
22 },
23);