mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-29 13:13:21 -07:00
repro: rich logging and focused tests
This commit is contained in:
@@ -1888,18 +1888,13 @@ console.log(JSON.stringify({decision: "block", systemMessage: "Disabled hook sho
|
||||
expect(disabledHookLog).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should respect disabled hooks across multiple operations', async () => {
|
||||
rig.setup('should respect disabled hooks across multiple operations', {
|
||||
fakeResponsesPath: join(
|
||||
import.meta.dirname,
|
||||
'hooks-system.disabled-via-command.responses',
|
||||
),
|
||||
});
|
||||
it.only('should respect disabled hooks across multiple operations', async () => {
|
||||
// 1. First setup to get the test directory and prepare the hook scripts
|
||||
rig.setup('should respect disabled hooks across multiple operations');
|
||||
console.log(`[Test] testDir: ${rig.testDir}`);
|
||||
|
||||
// Create two hook scripts - one that will be disabled, one that won't
|
||||
const activeHookScript = `const fs = require('fs');
|
||||
console.log(JSON.stringify({decision: "allow", systemMessage: "Active hook executed"}));`;
|
||||
|
||||
const disabledHookScript = `const fs = require('fs');
|
||||
console.log(JSON.stringify({decision: "block", systemMessage: "Disabled hook should not execute", reason: "This hook is disabled"}));`;
|
||||
|
||||
@@ -1909,11 +1904,14 @@ console.log(JSON.stringify({decision: "block", systemMessage: "Disabled hook sho
|
||||
writeFileSync(activePath, activeHookScript);
|
||||
writeFileSync(disabledPath, disabledHookScript);
|
||||
|
||||
const normalizedDisabledCmd = normalizePath(`node "${disabledPath}"`);
|
||||
console.log(`[Test] normalizedDisabledCmd: ${normalizedDisabledCmd}`);
|
||||
|
||||
rig.setup('should respect disabled hooks across multiple operations', {
|
||||
settings: {
|
||||
hooksConfig: {
|
||||
enabled: true,
|
||||
disabled: [normalizePath(`node "${disabledPath}"`)!], // Disable the second hook,
|
||||
disabled: [normalizedDisabledCmd!], // Disable the second hook,
|
||||
},
|
||||
hooks: {
|
||||
BeforeTool: [
|
||||
@@ -1926,7 +1924,7 @@ console.log(JSON.stringify({decision: "block", systemMessage: "Disabled hook sho
|
||||
},
|
||||
{
|
||||
type: 'command',
|
||||
command: normalizePath(`node "${disabledPath}"`),
|
||||
command: normalizedDisabledCmd!,
|
||||
timeout: 5000,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -269,6 +269,12 @@ 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),
|
||||
@@ -338,6 +344,12 @@ 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,
|
||||
|
||||
@@ -1253,6 +1253,11 @@ 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 &&
|
||||
@@ -1410,6 +1415,11 @@ 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