fix(FN-000): harden vitest child process isolation

This commit is contained in:
gsxdsm
2026-04-30 13:44:59 -07:00
parent 400be4487f
commit 3db00440d9
9 changed files with 288 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import { mkdirSync, writeFileSync } from "node:fs";
import * as fsPromises from "node:fs/promises";
import { execSync, spawnSync } from "node:child_process";
import { homedir, tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
@@ -83,4 +84,22 @@ describe("test isolation setup", () => {
"targeted protected repo .fusion directory",
);
});
it("blocks real AI CLI subprocesses from running in tests", () => {
expect(() => spawnSync("droid", ["--version"])).toThrow(
"Real AI CLI launch blocked during tests",
);
expect(() => execSync("claude --version", { encoding: "utf-8" })).toThrow(
"Real AI CLI launch blocked during tests",
);
});
it("still allows bounded local subprocesses", () => {
const result = spawnSync(process.execPath, ["-e", "process.exit(0)"], {
encoding: "utf-8",
});
expect(result.status).toBe(0);
expect(result.error).toBeUndefined();
});
});