| 24 | let server: RunningServer | undefined; |
| 25 | |
| 26 | function rmSyncRobust(path: string): void { |
| 27 | try { |
| 28 | rmSync(path, { recursive: true, force: true, maxRetries: 60, retryDelay: 250 }); |
| 29 | } catch (error) { |
| 30 | const code = (error as NodeJS.ErrnoException).code; |
| 31 | if (code !== 'EPERM' && code !== 'EBUSY' && code !== 'ENOTEMPTY') throw error; |
| 32 | // Best-effort cleanup: a child process may still hold the cwd or be |
| 33 | // writing into the dir after server.close(); the OS reclaims the temp dir |
| 34 | // later and a cleanup hiccup must not fail an otherwise-passing test. |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | beforeEach(() => { |
| 39 | tmpDir = mkdtempSync(join(tmpdir(), 'kimi-server-fs-git-test-')); |