From f92b460b9c3f2cb043695f7fea61e1c2a00bf61d Mon Sep 17 00:00:00 2001 From: Landon Cox Date: Wed, 8 Jul 2026 20:44:43 -0700 Subject: [PATCH] fix: mock accessSync in workdir-setup test to avoid macOS false failure The test 'falls back to nearest existing ancestor when no ancestor fails the access check' assumed all real ancestor directories pass the W_OK|X_OK check. On macOS, /var/folders/dl fails this check, causing the test to fail because a system directory becomes the blocker instead of falling through to the nearestExisting fallback. Fix by mocking accessSync to always pass, ensuring the fallback path is reliably exercised regardless of host filesystem permissions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/workdir-setup.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/workdir-setup.test.ts b/src/workdir-setup.test.ts index ab7421848..c54d811e8 100644 --- a/src/workdir-setup.test.ts +++ b/src/workdir-setup.test.ts @@ -534,8 +534,10 @@ describe('ensureDirectory EACCES diagnostic', () => { { code: 'EACCES' } ); (fs.mkdirSync as jest.Mock).mockImplementationOnce(() => { throw eacces; }); - // accessSync delegates to actualFs (all real dirs are writable), so no ancestor - // fails the check and the code falls back to the nearest existing ancestor. + // Mock accessSync to always pass so no ancestor fails the check and the code + // falls back to the nearest existing ancestor. Without this, system directories + // (e.g. /var/folders on macOS) may fail W_OK|X_OK and become the blocker. + (fs.accessSync as jest.Mock).mockImplementation(() => undefined); expect(() => workdirSetupTestHelpers.ensureDirectory(targetDir)).toThrow( new RegExp(`Blocked by: .*existing-parent`)