fix(tests): wrap rmSync cleanup in try/catch for Windows EPERM

maxRetries doesn't help with EPERM (only EBUSY/EMFILE/ENFILE).
Windows holds directory handles after close, making rmSync fail
in afterEach. Swallowing the error is safe — OS cleans temp dirs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson 2026-03-22 10:12:42 -06:00
parent 6923ddd519
commit e35bc2fe15
8 changed files with 15 additions and 15 deletions

View file

@ -36,7 +36,7 @@ afterEach(() => {
process.chdir(savedCwd);
}
for (const d of tmpDirs) {
rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
tmpDirs.length = 0;
});

View file

@ -32,7 +32,7 @@ function makeTmpDir(): string {
afterEach(() => {
_resetPendingResolve();
for (const d of tmpDirs) {
rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM — OS cleans up temp dirs */ }
}
tmpDirs.length = 0;
});

View file

@ -29,7 +29,7 @@ function makeTmpDir(): string {
afterEach(() => {
for (const d of tmpDirs) {
rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
tmpDirs.length = 0;
});

View file

@ -90,7 +90,7 @@ test("loadDefinition: valid 3-step YAML returns correct structure", () => {
assert.deepEqual(def.steps[2].requires, ["outline"]);
assert.deepEqual(def.steps[2].produces, ["draft.md"]);
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
});
@ -235,7 +235,7 @@ test("loadDefinition: missing file → descriptive error", () => {
},
);
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
});
@ -258,7 +258,7 @@ steps:
},
);
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
});
@ -281,7 +281,7 @@ steps:
const def = loadDefinition(dir, "test-workflow");
assert.deepEqual(def.steps[1].requires, ["first"]);
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
});
@ -302,7 +302,7 @@ steps:
const def = loadDefinition(dir, "test-workflow");
assert.deepEqual(def.steps[1].contextFrom, ["first"]);
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
});
@ -738,7 +738,7 @@ steps:
const def = loadDefinition(dir, "test-workflow");
assert.equal(def.params, undefined);
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
});
@ -755,7 +755,7 @@ steps:
const def = loadDefinition(dir, "test-workflow");
assert.equal(def.description, undefined);
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
});
@ -773,6 +773,6 @@ steps:
assert.deepEqual(def.steps[0].requires, []);
assert.deepEqual(def.steps[0].produces, []);
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
});

View file

@ -52,7 +52,7 @@ function makeTmpDir(): string {
afterEach(() => {
for (const d of tmpDirs) {
rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
tmpDirs.length = 0;
});

View file

@ -32,7 +32,7 @@ function makeTmpDir(): string {
}
function cleanupDir(dir: string): void {
rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
/** Minimal valid graph for testing. */

View file

@ -39,7 +39,7 @@ function makeTmpDir(): string {
afterEach(() => {
for (const d of tmpDirs) {
rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
tmpDirs.length = 0;
});

View file

@ -34,7 +34,7 @@ function makeTmpBase(): string {
afterEach(() => {
for (const d of tmpDirs) {
rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
try { rmSync(d, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); } catch { /* Windows EPERM */ }
}
tmpDirs.length = 0;
});