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}`); });