| 35 | let server: RunningServer | undefined; |
| 36 | |
| 37 | function rmSyncRobust(path: string): void { |
| 38 | try { |
| 39 | rmSync(path, { recursive: true, force: true, maxRetries: 60, retryDelay: 250 }); |
| 40 | } catch (error) { |
| 41 | const code = (error as NodeJS.ErrnoException).code; |
| 42 | if (code !== 'EPERM' && code !== 'EBUSY' && code !== 'ENOTEMPTY') throw error; |
| 43 | // Best-effort cleanup: a child process may still hold the cwd or be |
| 44 | // writing into the dir after server.close(); the OS reclaims the temp dir |
| 45 | // later and a cleanup hiccup must not fail an otherwise-passing test. |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | beforeEach(() => { |
| 50 | tmpDir = mkdtempSync(join(tmpdir(), 'kimi-server-questions-test-')); |