diff --git a/gitnexus/test/helpers/test-db.ts b/gitnexus/test/helpers/test-db.ts index 5be063a2cf..3c845dbe03 100644 --- a/gitnexus/test/helpers/test-db.ts +++ b/gitnexus/test/helpers/test-db.ts @@ -21,6 +21,9 @@ const cleanupBackoffMs = (attempt: number): number => 100 * (attempt + 1); const shouldSwallowCleanupError = (err: unknown): boolean => { const code = (err as NodeJS.ErrnoException | undefined)?.code; + // ENOTEMPTY can race on any platform (macOS node-gyp cache, Linux + // parallel test teardown) — swallow after retries are exhausted. + if (code === 'ENOTEMPTY') return true; return process.platform === 'win32' && WINDOWS_NATIVE_LOCK_CODES.has(code ?? ''); }; diff --git a/gitnexus/test/integration/antigravity-hook-e2e.test.ts b/gitnexus/test/integration/antigravity-hook-e2e.test.ts index 5e8683471f..617214c0c1 100644 --- a/gitnexus/test/integration/antigravity-hook-e2e.test.ts +++ b/gitnexus/test/integration/antigravity-hook-e2e.test.ts @@ -20,6 +20,7 @@ import { spawnSync } from 'child_process'; import fs from 'fs'; import fsp from 'fs/promises'; import path from 'path'; +import { cleanupTempDir, cleanupTempDirSync } from '../helpers/test-db.js'; import os from 'os'; import { runHook, parseHookOutput } from '../utils/hook-test-helpers.js'; import { setupCommand } from '../../src/cli/setup.js'; @@ -84,8 +85,8 @@ beforeAll(async () => { afterAll(async () => { process.env.HOME = originalHome; process.env.USERPROFILE = originalUserProfile; - if (tempHome) await fsp.rm(tempHome, { recursive: true, force: true }); - if (tmpDir) fs.rmSync(tmpDir, { recursive: true, force: true }); + if (tempHome) await cleanupTempDir(tempHome); + if (tmpDir) cleanupTempDirSync(tmpDir); }); describe('antigravity hook adapter e2e', () => { @@ -402,7 +403,7 @@ describe('antigravity hook adapter e2e', () => { }); afterAll(() => { - fs.rmSync(cleanupRoot, { recursive: true, force: true }); + cleanupTempDirSync(cleanupRoot); }); it('ignores AfterTool when no .gitnexus exists in cwd or any ancestor', () => {