From a108b7f33a8258699706d798010d533fca650c46 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 22 Jul 2026 10:53:17 -0700 Subject: [PATCH] =?UTF-8?q?test(autopilot):=20make=20#2794=20wrapper-scrip?= =?UTF-8?q?t=20tests=20hermetic=20=E2=80=94=20fake=20gbrain=20on=20PATH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit writeWrapperScript calls resolveGbrainCliPath(), which shells out to `which gbrain` and throws on CI runners where no gbrain binary is installed. The two new --interval threading tests failed only in CI (dev machines have gbrain on PATH). Prepend a fake executable to PATH for the describe block so resolution is deterministic everywhere. Co-Authored-By: Claude Fable 5 --- test/autopilot-install.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/autopilot-install.test.ts b/test/autopilot-install.test.ts index a5543d8ac..4ed286b73 100644 --- a/test/autopilot-install.test.ts +++ b/test/autopilot-install.test.ts @@ -89,6 +89,24 @@ describe('detectInstallTarget', () => { // wrapper always exec'd bare `autopilot --repo ...` (default 300s). The // wrapper's exec line must carry the interval when one is known. describe('autopilot wrapper script — --interval threading (#2794)', () => { + // writeWrapperScript resolves the gbrain CLI via `which gbrain`; CI runners + // don't have the binary installed, so put a fake one on PATH to keep the + // test hermetic (deterministic on dev machines too — fake bin wins). + let pathSnapshot: string | undefined; + + beforeEach(() => { + pathSnapshot = process.env.PATH; + const bin = join(tmp, 'bin'); + mkdirSync(bin, { recursive: true }); + writeFileSync(join(bin, 'gbrain'), '#!/bin/sh\n', { mode: 0o755 }); + process.env.PATH = `${bin}:${process.env.PATH ?? ''}`; + }); + + afterEach(() => { + if (pathSnapshot === undefined) delete process.env.PATH; + else process.env.PATH = pathSnapshot; + }); + test('exec line carries --interval when provided', () => { const wrapperPath = writeWrapperScript('/tmp/some repo', 600); const script = readFileSync(wrapperPath, 'utf8');