mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-30 21:52:50 -07:00
fix(hooks): final verified fixes for Windows flakiness
This commit is contained in:
@@ -517,10 +517,7 @@ console.log(JSON.stringify({
|
||||
});
|
||||
|
||||
describe('BeforeToolSelection Hooks - Tool Configuration', () => {
|
||||
it.only('should modify tool selection with BeforeToolSelection hooks', async () => {
|
||||
// 1. Initial setup to establish test directory
|
||||
rig.setup('BeforeToolSelection Hooks');
|
||||
|
||||
it('should modify tool selection with BeforeToolSelection hooks', async () => {
|
||||
const toolConfigJson = JSON.stringify({
|
||||
hookSpecificOutput: {
|
||||
hookEventName: 'BeforeToolSelection',
|
||||
@@ -1763,10 +1760,7 @@ console.log(JSON.stringify({
|
||||
});
|
||||
|
||||
describe('Hook Disabling', () => {
|
||||
it.only('should not execute hooks disabled in settings file', async () => {
|
||||
// 1. Initial setup to establish test directory
|
||||
rig.setup('Hook Disabling');
|
||||
|
||||
it('should not execute hooks disabled in settings file', async () => {
|
||||
const enabledMsg = 'EXECUTION_ALLOWED_BY_HOOK_A';
|
||||
const disabledMsg = 'EXECUTION_BLOCKED_BY_HOOK_B';
|
||||
|
||||
@@ -1834,10 +1828,7 @@ console.log(JSON.stringify({
|
||||
expect(disabledHookLog).toBeUndefined();
|
||||
});
|
||||
|
||||
it.only('should respect disabled hooks across multiple operations', async () => {
|
||||
// 1. Initial setup to establish test directory
|
||||
rig.setup('Hook Disabling');
|
||||
|
||||
it('should respect disabled hooks across multiple operations', async () => {
|
||||
const activeMsg = 'MULTIPLE_OPS_ENABLED_HOOK';
|
||||
const disabledMsg = 'MULTIPLE_OPS_DISABLED_HOOK';
|
||||
|
||||
|
||||
@@ -966,10 +966,6 @@ export class CoreToolScheduler {
|
||||
// The active tool is finished. Move it to the completed batch.
|
||||
const completedCall = activeCall as CompletedToolCall;
|
||||
|
||||
if (process.env['CI'] === 'true' || process.env['VERBOSE'] === 'true') {
|
||||
console.log(`[CoreToolScheduler] Completed tool call: ${completedCall.request.name}, status: ${completedCall.status}`);
|
||||
}
|
||||
|
||||
this.completedToolCallsForBatch.push(completedCall);
|
||||
logToolCall(this.config, new ToolCallEvent(completedCall));
|
||||
|
||||
|
||||
@@ -233,16 +233,6 @@ please review the project settings (.gemini/settings.json) and remove them.`;
|
||||
} as HookRegistryEntry);
|
||||
const isDisabled = disabledHooks.includes(hookName);
|
||||
|
||||
if (process.env['CI'] === 'true' || process.env['VERBOSE'] === 'true') {
|
||||
console.log(`[HookRegistry] Processing hook: "${hookName}"`);
|
||||
if (isDisabled) {
|
||||
console.log(`[HookRegistry] Hook is DISABLED (found in disabledHooks list)`);
|
||||
}
|
||||
if (disabledHooks.length > 0) {
|
||||
console.log(`[HookRegistry] Current disabledHooks: ${JSON.stringify(disabledHooks)}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Add source to hook config
|
||||
hookConfig.source = source;
|
||||
|
||||
|
||||
@@ -268,12 +268,6 @@ export class HookRunner {
|
||||
shellConfig.shell,
|
||||
);
|
||||
|
||||
if (process.env['CI'] === 'true' || process.env['VERBOSE'] === 'true') {
|
||||
console.log(`[HookRunner] shellConfig: ${JSON.stringify(shellConfig)}`);
|
||||
console.log(`[HookRunner] command: ${command}`);
|
||||
console.log(`[HookRunner] cwd: ${input.cwd}`);
|
||||
}
|
||||
|
||||
// Set up environment variables
|
||||
const env = {
|
||||
...sanitizeEnvironment(process.env, this.config.sanitizationConfig),
|
||||
@@ -339,9 +333,6 @@ export class HookRunner {
|
||||
});
|
||||
|
||||
child.on('exit', (code, signal) => {
|
||||
if (process.env['CI'] === 'true' || process.env['VERBOSE'] === 'true') {
|
||||
console.log(`[HookRunner] Hook exit. code: ${code}, signal: ${signal}`);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle process exit
|
||||
@@ -349,12 +340,6 @@ export class HookRunner {
|
||||
clearTimeout(timeoutHandle);
|
||||
const duration = Date.now() - startTime;
|
||||
|
||||
if (process.env['CI'] === 'true' || process.env['VERBOSE'] === 'true') {
|
||||
console.log(`[HookRunner] Hook closed. exitCode: ${exitCode}, duration: ${duration}ms`);
|
||||
console.log(`[HookRunner] stdout: ${stdout}`);
|
||||
console.log(`[HookRunner] stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
if (timedOut) {
|
||||
resolve({
|
||||
hookConfig,
|
||||
@@ -443,9 +428,6 @@ export class HookRunner {
|
||||
text: string,
|
||||
exitCode: number,
|
||||
): HookOutput {
|
||||
if (process.env['CI'] === 'true' || process.env['VERBOSE'] === 'true') {
|
||||
console.log(`[HookRunner] convertPlainTextToHookOutput: exitCode=${exitCode}, text="${text}"`);
|
||||
}
|
||||
if (exitCode === EXIT_CODE_SUCCESS) {
|
||||
// Success - treat as system message or additional context
|
||||
return {
|
||||
|
||||
@@ -361,19 +361,10 @@ export class TestRig {
|
||||
this.testDir = join(testFileDir, sanitizedName);
|
||||
this.homeDir = join(testFileDir, sanitizedName + '-home');
|
||||
|
||||
if (env['VERBOSE'] === 'true' || env['CI'] === 'true') {
|
||||
console.log(`[TestRig] Setting up test: ${this.testName}`);
|
||||
console.log(`[TestRig] testDir: ${this.testDir}`);
|
||||
console.log(`[TestRig] homeDir: ${this.homeDir}`);
|
||||
}
|
||||
|
||||
if (!this._initialized) {
|
||||
// Clean up existing directories from previous runs (e.g. retries)
|
||||
const cleanDir = (dir: string) => {
|
||||
if (fs.existsSync(dir)) {
|
||||
if (env['VERBOSE'] === 'true' || env['CI'] === 'true') {
|
||||
console.log(`[TestRig] Cleaning up existing directory: ${dir}`);
|
||||
}
|
||||
for (let i = 0; i < 5; i++) {
|
||||
try {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
@@ -771,11 +762,6 @@ export class TestRig {
|
||||
});
|
||||
this._spawnedProcesses.push(child);
|
||||
|
||||
if (env['VERBOSE'] === 'true' || env['CI'] === 'true') {
|
||||
console.log(`[TestRig] Running: ${command} ${commandArgs.join(' ')}`);
|
||||
console.log(`[TestRig] CWD: ${this.testDir}`);
|
||||
}
|
||||
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
|
||||
@@ -1259,11 +1245,6 @@ export class TestRig {
|
||||
}[] = [];
|
||||
|
||||
for (const logData of parsedLogs) {
|
||||
if (env['VERBOSE'] === 'true' || env['CI'] === 'true') {
|
||||
if (logData.attributes?.['event.name']?.includes('tool')) {
|
||||
console.log(`[TestRig] Found tool-related log: ${JSON.stringify(logData.attributes)}`);
|
||||
}
|
||||
}
|
||||
// Look for tool call logs
|
||||
if (
|
||||
logData.attributes &&
|
||||
@@ -1416,11 +1397,6 @@ export class TestRig {
|
||||
}[] = [];
|
||||
|
||||
for (const logData of parsedLogs) {
|
||||
if (env['VERBOSE'] === 'true' || env['CI'] === 'true') {
|
||||
if (logData.attributes?.['event.name']?.includes('hook')) {
|
||||
console.log(`[TestRig] Found hook-related log: ${JSON.stringify(logData.attributes)}`);
|
||||
}
|
||||
}
|
||||
// Look for tool call logs
|
||||
if (
|
||||
logData.attributes &&
|
||||
|
||||
Reference in New Issue
Block a user