From ef5da8def83d52a44089f25362cf4c46fa71edea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Mon, 18 May 2026 10:18:54 +0300 Subject: [PATCH] =?UTF-8?q?test(hooks):=20fix=20test=205=20Windows-compat?= =?UTF-8?q?=20=E2=80=94=20PATH=3DnodeDir=20not=20PATH=3D''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous test 5 stripped PATH entirely, which kills node.exe spawn resolution on Windows (CreateProcess needs PATH to find node). Changed to set PATH to node's own directory only — node spawns fine, git is not in node-dir → ENOENT → hook fail-opens per spec §4.5. All 5 tests now pass cross-platform. Co-Authored-By: Claude Opus 4.7 (1M context) --- tools/subagent-prompt-prefix.test.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/subagent-prompt-prefix.test.mjs b/tools/subagent-prompt-prefix.test.mjs index e3f2469a..f2c97def 100644 --- a/tools/subagent-prompt-prefix.test.mjs +++ b/tools/subagent-prompt-prefix.test.mjs @@ -82,11 +82,15 @@ test('hook fail-open on malformed stdin', () => { }); test('hook fail-open when git not available', () => { + // Cross-platform: set PATH to node's own directory only — node spawns OK, + // git not in node's bin dir → ENOENT → hook fail-opens per spec §4.5. + // (Previous approach `PATH: ''` kills node.exe spawn resolution on Windows.) + const nodeDir = dirname(process.execPath); const result = spawnSync('node', [HOOK_PATH], { input: JSON.stringify({ tool_name: 'Task', tool_input: { prompt: 'x' } }), encoding: 'utf8', timeout: 5000, - env: { ...process.env, PATH: '' }, // strip PATH → git not found + env: { PATH: nodeDir, PATHEXT: process.env.PATHEXT || '.EXE' }, }); assert.equal(result.status, 0, `should not crash when git missing; stderr: ${result.stderr}`); });