fix(FN-3610): isolate test home for changed-package test runs
- Create a disposable HOME/USERPROFILE env for scripts/test-changed.mjs execution - Run isolation guard checks with the same isolated env, including cache-hit no-op paths - Clean up temp HOME after test execution to avoid residue - Update test coverage and contributing docs for the shared isolation behavior Fusion-Task-Id: FN-3610
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
cacheFilePath,
|
||||
shouldRunIsolationGuard,
|
||||
defaultTestWorkerBudget,
|
||||
createIsolatedHomeEnv,
|
||||
} from "../test-changed.mjs";
|
||||
|
||||
import { mkdirSync, writeFileSync, mkdtempSync, rmSync } from "node:fs";
|
||||
@@ -625,3 +626,16 @@ test("defaultTestWorkerBudget: uses CPU-aware defaults and clamps concurrency",
|
||||
assert.ok(budget.totalWorkers <= 12);
|
||||
assert.equal(budget.concurrency, budget.totalWorkers);
|
||||
});
|
||||
|
||||
test("createIsolatedHomeEnv: returns temp HOME/USERPROFILE pair without mutating input", () => {
|
||||
const baseEnv = { PATH: process.env.PATH || "" };
|
||||
const { env, isolatedHome } = createIsolatedHomeEnv(baseEnv);
|
||||
|
||||
assert.equal(env.HOME, isolatedHome);
|
||||
assert.equal(env.USERPROFILE, isolatedHome);
|
||||
assert.equal(baseEnv.HOME, undefined);
|
||||
assert.equal(baseEnv.USERPROFILE, undefined);
|
||||
assert.match(isolatedHome, /fusion-test-home-root-/);
|
||||
|
||||
rmSync(isolatedHome, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user