Files
rea/tests/boundary/browser/runtimeFixtureCleanup.test.ts
morluto 131b2d85f3 fix(verify): report every owned cleanup failure before success
Use one cleanup owner across browser, Frida and JEB verifiers. Attempt all independent cleanup tasks, retain primary failures, and emit successful reports only after cleanup. Remove the superseded browser helper and duplicate tests.

Validation: cleanup aggregation and runtime fixture tests, build and static checks passed. No real Frida or JEB run.
2026-10-14 13:40:53 +08:00

47 lines
1.6 KiB
TypeScript

import { execFile } from "node:child_process";
import { readdir } from "node:fs/promises";
import { promisify } from "node:util";
import { expect, it } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
it.skipIf(process.platform === "win32")(
"rejects an exited fixture before returning a lease and removes its profile",
async () => {
const root = await createTestTempDirectory("rea-runtime-startup-failure-");
const helper = new URL(
"../../../scripts/lib/browser-runtime-fixture-lifecycle.mjs",
import.meta.url,
);
const script = `
const { startRuntimeFixtureBrowser } = await import(${JSON.stringify(helper.href)});
// Node rejects Chrome's arguments immediately, exercising actual process exit.
try {
const fixture = await startRuntimeFixtureBrowser(process.execPath, 'http://127.0.0.1');
await fixture.close();
throw new Error('Expected startup failure');
} catch (error) {
if (error._tag !== 'BrowserStartupError') throw error;
console.log(JSON.stringify({
failure: error.failure,
exitCode: error.exitCode,
stderr: error.stderr,
}));
}
`;
const { stdout } = await promisify(execFile)(
process.execPath,
["--input-type=module", "-e", script],
{
env: { ...process.env, TMPDIR: root, TMP: root, TEMP: root },
timeout: 10_000,
},
);
expect(JSON.parse(stdout)).toEqual({
failure: "exited",
exitCode: expect.any(Number),
stderr: expect.stringContaining("bad option"),
});
expect(await readdir(root)).toEqual([]);
},
);