fix(engine-tests): eliminate temp-dir leak and raise subprocess guard for concurrent workspace runs

Two engine merger tests created mkdtempSync workspaces directly in tmpdir()
under the tracked `fusion-test-` prefix; under full-suite concurrent load
the post-run check-test-isolation flagged them as leaks. Route both
(`merger-no-op-fix-finalize.test.ts`, `merger-verification-fix-already-on-main.test.ts`)
through FUSION_TEST_WORKER_ROOT like sibling merger tests so they nest
inside the already-tracked worker root.

Bump engine vitest subprocess guard from 60s to 120s and testTimeout to
30s — plain git commands (branch -d, worktree remove) queued behind
system contention during `pnpm -r --workspace-concurrency=2` runs were
timing out. The guard only fires on hangs, so healthy tests pay nothing.

Also bundles in-progress dashboard mobile-breakpoint regex/CSS test
updates and docs index additions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-22 20:20:42 -07:00
parent a96e2ab02b
commit f58fb8955a
60 changed files with 138 additions and 95 deletions

View File

@@ -39,6 +39,10 @@ function assertIsolatedWorkspace(dir: string): void {
expect(resolve(dir).startsWith(resolve(repoRoot))).toBe(false);
}
function testTempParent(): string {
return process.env.FUSION_TEST_WORKER_ROOT ?? tmpdir();
}
const STUB_SETTINGS = {
...DEFAULT_SETTINGS,
mergeIntegrationWorktree: "cwd-main" as const,
@@ -49,7 +53,7 @@ describe("commitOrAmendMergeWithFixes no-op finalize", () => {
let dir: string;
beforeEach(() => {
dir = mkdtempSync(join(tmpdir(), "fusion-test-merger-noop-"));
dir = mkdtempSync(join(testTempParent(), "fusion-test-merger-noop-"));
assertIsolatedWorkspace(dir);
initRepo(dir);
});

View File

@@ -10,6 +10,10 @@ function git(dir: string, cmd: string): string {
return execSync(cmd, { cwd: dir, stdio: "pipe" }).toString().trim();
}
function testTempParent(): string {
return process.env.FUSION_TEST_WORKER_ROOT ?? tmpdir();
}
const created = new Set<string>();
afterEach(() => {
for (const dir of created) rmSync(dir, { recursive: true, force: true });
@@ -17,7 +21,7 @@ afterEach(() => {
});
function mkRepo(): string {
const dir = mkdtempSync(join(tmpdir(), "fusion-test-merge-already-on-main-"));
const dir = mkdtempSync(join(testTempParent(), "fusion-test-merge-already-on-main-"));
created.add(dir);
git(dir, "git init -b main");
git(dir, 'git config user.email "test@example.com"');

View File

@@ -133,7 +133,7 @@ describe("reliability interactions: explicit duplicate marker sweep", () => {
expect(await (fx.manager as any).resolveExplicitDuplicateMarkerTasks()).toBe(10);
const remainingAfterSecond = await fx.store.listTasks({ includeArchived: false });
expect(remainingAfterSecond.filter((task) => ids.includes(task.id))).toHaveLength(0);
});
}, 20_000);
it("fails open when one delete throws and continues processing later tasks", async () => {
const fx = await makeReliabilityFixture();

View File

@@ -718,8 +718,11 @@ describe("FN-5279 reliability interactions: merge reuse task worktree", () => {
expect(orderedFreshAcquireIndex).toBeGreaterThanOrEqual(0);
expect(orderedFreshAcquiredIndex).toBeGreaterThanOrEqual(0);
expect(orderedFallbackIndex).toBeGreaterThanOrEqual(0);
expect(orderedFreshAcquireIndex).toBeLessThan(orderedFreshAcquiredIndex);
expect(orderedFreshAcquiredIndex).toBeLessThan(orderedFallbackIndex);
// getRunAuditEvents() returns newest-first (timestamp DESC, rowid DESC), so the
// later-emitted fallback event should appear before fresh-acquired, which should
// appear before the earlier fresh-acquire marker.
expect(orderedFallbackIndex).toBeLessThan(orderedFreshAcquiredIndex);
expect(orderedFreshAcquiredIndex).toBeLessThan(orderedFreshAcquireIndex);
} finally {
await fixture.cleanup();
}

View File

@@ -26,6 +26,15 @@ export default defineConfig({
fileParallelism: true,
// Enable isolate to allow parallel execution of tests with conflicting mocks
isolate: true,
// Engine real-git tests spawn many subprocesses; under full-suite concurrent
// load even 60 s can fire prematurely. Bump to 120 s — the guard only fires
// on hangs, so healthy tests pay nothing.
env: {
FUSION_TEST_SUBPROCESS_TIMEOUT_MS: "120000",
},
// Real-git integration tests need more than the default 5 s under concurrent
// load (other packages run tests at the same time via pnpm recursive).
testTimeout: 30_000,
coverage: {
enabled: false,
reporter: ["text", "html", "json"],