mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-12 12:26:57 -07:00
fix(hooks): force child_process PTY and fix settings structure in tests
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
@@ -539,6 +539,7 @@ export class TestRig {
|
||||
return {
|
||||
...cleanEnv,
|
||||
GEMINI_CLI_HOME: this.homeDir!,
|
||||
GEMINI_PTY_INFO: 'child_process',
|
||||
...extraEnv,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user