Files
reverse-engineering-anything/tests/boundary/process/bunVerifierOwnerInitialization.test.ts
T
morluto 7bcefead69 test: strengthen and prune audited test coverage (#8573)
* test: strengthen and prune audited test coverage

* test: require delivered DeepSeek skill instructions

* test: keep schema fixture types private

* test: verify Gemini receives skill instructions

* test: bind Qwen skill evidence to its tool result

* test: report NativeAOT verifier checks precisely

* fix: verify Ghidra cleanup paths reliably

* fix: verify Command Code skill activation

* test: tighten cleanup and fixture checks

* test: verify packet capture evidence is recorded

* fix: report HTTP3 capture provenance accurately

* test: preserve resource coverage through MCP

* test: prune repeated assertions and retain cancellation identity

* fix: validate client verifier fixture paths

* test: skip Copilot verifier cases on Windows

* test: keep verifier setup target relative
2026-11-02 02:13:32 +08:00

81 lines
3.1 KiB
TypeScript

import { spawnSync } from "node:child_process";
import { mkdtemp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { expect, it } from "vitest";
it.each([
["initialization failure", "init", true],
["initialization and root cleanup failures", "init_close", false],
["command failure", "run", true],
["command cleanup failure", "close", false],
] as const)(
"retains the verifier root correctly after %s",
async (_name, failure, rootClosed) => {
const root = await mkdtemp(join(tmpdir(), "rea-bun-owner-test-"));
try {
await mkdir(join(root, "scripts", "lib"), { recursive: true });
await mkdir(join(root, "dist", "process"), { recursive: true });
await mkdir(join(root, "dist", "domain"), { recursive: true });
await writeFile(
join(root, "scripts", "verify-bun-standalone.mjs"),
await readFile(
new URL(
"../../../scripts/verify-bun-standalone.mjs",
import.meta.url,
),
),
);
await writeFile(
join(root, "scripts", "lib", "verifier-cleanup.mjs"),
await readFile(
new URL("../../../scripts/lib/verifier-cleanup.mjs", import.meta.url),
),
);
await writeFile(
join(root, "scripts", "lib", "verify-commands.mjs"),
`export async function createVerifierCommands() {
if (process.env.FAULT.startsWith("init")) throw new Error("owner load refused");
return { async exec() { throw new Error("command refused"); }, async close() {
if (process.env.FAULT === "close") throw new Error("owner close refused");
} };
}`,
);
await writeFile(
join(root, "dist", "process", "PrivateRuntimeRoot.js"),
`import { writeFile } from "node:fs/promises";
export class PrivateRuntimeRoot { static async create() { return {
path: process.env.ROOT, async close() { if (process.env.FAULT === "init_close") throw new Error("root close refused"); await writeFile(process.env.CLOSED, "closed"); }
}; } }`,
);
await writeFile(
join(root, "dist", "domain", "evidence.js"),
`export function parseEvidence() { throw new Error("unexpected"); }`,
);
const marker = join(root, "closed");
const result = spawnSync(
process.execPath,
[join(root, "scripts", "verify-bun-standalone.mjs")],
{
encoding: "utf8",
timeout: 10_000,
env: { ...process.env, ROOT: root, CLOSED: marker, FAULT: failure },
},
);
expect(result.status).not.toBe(0);
expect(result.stderr).toContain(
failure.startsWith("init") ? "owner load refused" : "command refused",
);
if (failure === "close")
expect(result.stderr).toContain("owner close refused");
if (failure === "init_close")
expect(result.stderr).toContain("root close refused");
expect(await readFile(marker, "utf8").catch(() => null)).toBe(
rootClosed ? "closed" : null,
);
} finally {
await rm(root, { recursive: true, force: true });
}
},
);