From 9da524bc1fb21a8474dd96dda3dea0ecce6a0c74 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 26 May 2026 14:49:29 +0100 Subject: [PATCH 1/2] fix(test): use retry cleanup in antigravity e2e to prevent ENOTEMPTY flake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace bare `fsp.rm` / `fs.rmSync` in antigravity-hook-e2e.test.ts afterAll with `cleanupTempDir` / `cleanupTempDirSync` from test-db.ts which retry with backoff on transient filesystem errors. Also make `shouldSwallowCleanupError` swallow ENOTEMPTY on all platforms (was Windows-only). The CI failure on macOS was ENOTEMPTY on a deeply nested node-gyp cache directory inside the temp HOME — a cleanup-time race that retries usually resolve, but the final attempt must not crash the test suite if the race persists. --- gitnexus/test/helpers/test-db.ts | 3 +++ gitnexus/test/integration/antigravity-hook-e2e.test.ts | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) 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..1ff5883cbe 100644 --- a/gitnexus/test/integration/antigravity-hook-e2e.test.ts +++ b/gitnexus/test/integration/antigravity-hook-e2e.test.ts @@ -18,8 +18,8 @@ import { describe, it, expect, beforeAll, afterAll } from 'vitest'; 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 +84,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 +402,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', () => { From c5ae12d7f547b625688e2a7f83ff9421e0c99da0 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 26 May 2026 15:12:38 +0100 Subject: [PATCH 2/2] fix: restore fsp import needed for mkdtemp/mkdir --- gitnexus/test/integration/antigravity-hook-e2e.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/gitnexus/test/integration/antigravity-hook-e2e.test.ts b/gitnexus/test/integration/antigravity-hook-e2e.test.ts index 1ff5883cbe..617214c0c1 100644 --- a/gitnexus/test/integration/antigravity-hook-e2e.test.ts +++ b/gitnexus/test/integration/antigravity-hook-e2e.test.ts @@ -18,6 +18,7 @@ import { describe, it, expect, beforeAll, afterAll } from 'vitest'; 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';