Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests2/harness/file-boundary-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { VitestTestRunner } from "vitest/runners";
import type { File } from "@vitest/runner";
import { setProjectRoot } from "../../src/server/bobbit-dir.js";
import { resetAgentDirStateForTests } from "../../src/server/agent-dir-config.js";

const BASELINE_CWD = process.cwd();

// isolate:false files share a fork's module graph, so the project-root and
// agent-dir singletons leak between files. onCollectStart is the only hook that
// runs per file before its module loads; env is left to the fork-scoped gateway.
export default class FileBoundaryRunner extends VitestTestRunner {
onCollectStart(file: File): void {
setProjectRoot(BASELINE_CWD);
resetAgentDirStateForTests();
return super.onCollectStart(file);
}
}
4 changes: 4 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const shared = {
},
};
const tier1SetupFiles = ["tests2/harness/tier1-spawn-guard.ts"];
// Per-file reset of leaking dir singletons for the isolate:false projects.
const fileBoundaryRunner = "tests2/harness/file-boundary-runner.ts";

const coverage = {
provider: "v8" as const,
Expand Down Expand Up @@ -99,6 +101,7 @@ export default defineConfig({
...shared,
name: "v2-core",
environment: "node",
runner: fileBoundaryRunner,
setupFiles: tier1SetupFiles,
include: execution.core,
},
Expand All @@ -123,6 +126,7 @@ export default defineConfig({
...shared,
name: "v2-integration",
environment: "node",
runner: fileBoundaryRunner,
setupFiles: tier1SetupFiles,
include: execution.integration,
testTimeout: 60_000,
Expand Down
Loading