Skip to content

Commit 0360cb9

Browse files
committed
fix(test): tolerate ContextBench temp cleanup races
1 parent 6aed9d1 commit 0360cb9

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

‎tests/contextbench-baseline-schema-gate.test.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ function childEnv(overrides: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
3636
return { ...env, ...overrides };
3737
}
3838

39+
function ignoreWindowsTempCleanupRace(error: unknown): void {
40+
const code = (error as NodeJS.ErrnoException).code;
41+
if (!['EBUSY', 'ENOTEMPTY', 'EPERM'].includes(code ?? '')) throw error;
42+
}
43+
3944
function tempSessionRoot(phase: 'phase40' | 'phase41' = 'phase40'): string {
4045
return path.join(
4146
mkdtempSync(path.join(tmpdir(), `contextbench-${phase}-schema-gate-`)),
@@ -398,10 +403,16 @@ describe('ContextBench Phase 40 schema gate', () => {
398403
};
399404
expect(trajectory.traj_data.pred_files).toContain('src/a.ts');
400405
} finally {
401-
rmSync(path.dirname(path.dirname(path.dirname(path.dirname(sessionRoot)))), {
402-
recursive: true,
403-
force: true
404-
});
406+
try {
407+
rmSync(path.dirname(path.dirname(path.dirname(path.dirname(sessionRoot)))), {
408+
recursive: true,
409+
force: true,
410+
maxRetries: 10,
411+
retryDelay: 200
412+
});
413+
} catch (error) {
414+
ignoreWindowsTempCleanupRace(error);
415+
}
405416
rmSync(repoPath, { recursive: true, force: true });
406417
rmSync(payloadDir, { recursive: true, force: true });
407418
rmSync(stubDir, { recursive: true, force: true });

0 commit comments

Comments
 (0)