| 1 | // @effect-diagnostics nodeBuiltinImport:off - retention assertions need an isolated process with explicit GC. |
| 2 | import * as NodeChildProcess from "node:child_process"; |
| 3 | import * as NodeURL from "node:url"; |
| 4 | import * as NodeUtil from "node:util"; |
| 5 | import { expect, it } from "vite-plus/test"; |
| 6 | const execFile = NodeUtil.promisify(NodeChildProcess.execFile); |
| 7 | it.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 | ); |