fix(hooks): force child_process PTY and fix settings structure in tests

This commit is contained in:
Taylor Mullen
2026-02-12 17:45:36 -08:00
parent f406576be8
commit 45ecc6de1c
2 changed files with 8 additions and 4 deletions
+7 -4
View File
@@ -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');
+1
View File
@@ -539,6 +539,7 @@ export class TestRig {
return {
...cleanEnv,
GEMINI_CLI_HOME: this.homeDir!,
GEMINI_PTY_INFO: 'child_process',
...extraEnv,
};
}