diff --git a/integration-tests/hooks-system.test.ts b/integration-tests/hooks-system.test.ts index d6d1dc61ff..373497492d 100644 --- a/integration-tests/hooks-system.test.ts +++ b/integration-tests/hooks-system.test.ts @@ -534,7 +534,11 @@ console.log(JSON.stringify({ describe('BeforeToolSelection Hooks - Tool Configuration', () => { it('should modify tool selection with BeforeToolSelection hooks', async () => { + // 1. Initial setup to establish test directory + rig.setup('BeforeToolSelection Hooks'); + const toolConfigJson = JSON.stringify({ + decision: 'allow', hookSpecificOutput: { hookEventName: 'BeforeToolSelection', toolConfig: { @@ -547,7 +551,9 @@ console.log(JSON.stringify({ // Use file-based hook to avoid quoting issues const hookScript = `console.log(JSON.stringify(${toolConfigJson}));`; const hookFilename = 'before_tool_selection_hook.js'; + const scriptPath = rig.createScript(hookFilename, hookScript); + // 2. Final setup with script path rig.setup('BeforeToolSelection Hooks', { fakeResponsesPath: join( import.meta.dirname, @@ -564,7 +570,7 @@ console.log(JSON.stringify({ hooks: [ { type: 'command', - command: `node ${hookFilename}`, + command: normalizePath(`node "${scriptPath}"`), timeout: 60000, }, ], @@ -574,9 +580,6 @@ console.log(JSON.stringify({ }, }); - // Create the hook script after setup - rig.createScript(hookFilename, hookScript); - // Create a test file rig.createFile('new_file_data.txt', 'test data'); diff --git a/packages/test-utils/src/test-rig.ts b/packages/test-utils/src/test-rig.ts index 87983ba0e3..776acd62ed 100644 --- a/packages/test-utils/src/test-rig.ts +++ b/packages/test-utils/src/test-rig.ts @@ -539,6 +539,7 @@ export class TestRig { return { ...cleanEnv, GEMINI_CLI_HOME: this.homeDir!, + GEMINI_PTY_INFO: 'child_process', ...extraEnv, }; }