mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-15 16:41:11 -07:00
fix(plan): Fix AskUser evals (#22074)
This commit is contained in:
@@ -487,7 +487,7 @@ export class AppRig {
|
||||
}
|
||||
|
||||
async waitForPendingConfirmation(
|
||||
toolNameOrDisplayName?: string | RegExp,
|
||||
toolNameOrDisplayName?: string | RegExp | string[],
|
||||
timeout = 30000,
|
||||
): Promise<PendingConfirmation> {
|
||||
const matches = (p: PendingConfirmation) => {
|
||||
@@ -498,6 +498,12 @@ export class AppRig {
|
||||
p.toolDisplayName === toolNameOrDisplayName
|
||||
);
|
||||
}
|
||||
if (Array.isArray(toolNameOrDisplayName)) {
|
||||
return (
|
||||
toolNameOrDisplayName.includes(p.toolName) ||
|
||||
toolNameOrDisplayName.includes(p.toolDisplayName || '')
|
||||
);
|
||||
}
|
||||
return (
|
||||
toolNameOrDisplayName.test(p.toolName) ||
|
||||
toolNameOrDisplayName.test(p.toolDisplayName || '')
|
||||
|
||||
@@ -353,6 +353,7 @@ export class TestRig {
|
||||
testName: string,
|
||||
options: {
|
||||
settings?: Record<string, unknown>;
|
||||
state?: Record<string, unknown>;
|
||||
fakeResponsesPath?: string;
|
||||
} = {},
|
||||
) {
|
||||
@@ -382,6 +383,9 @@ export class TestRig {
|
||||
|
||||
// Create a settings file to point the CLI to the local collector
|
||||
this._createSettingsFile(options.settings);
|
||||
|
||||
// Create persistent state file
|
||||
this._createStateFile(options.state);
|
||||
}
|
||||
|
||||
private _cleanDir(dir: string) {
|
||||
@@ -473,6 +477,24 @@ export class TestRig {
|
||||
);
|
||||
}
|
||||
|
||||
private _createStateFile(overrideState?: Record<string, unknown>) {
|
||||
if (!this.homeDir) throw new Error('TestRig homeDir is not initialized');
|
||||
const userGeminiDir = join(this.homeDir, GEMINI_DIR);
|
||||
mkdirSync(userGeminiDir, { recursive: true });
|
||||
|
||||
const state = deepMerge(
|
||||
{
|
||||
terminalSetupPromptShown: true, // Default to true in tests to avoid blocking prompts
|
||||
},
|
||||
overrideState ?? {},
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(userGeminiDir, 'state.json'),
|
||||
JSON.stringify(state, null, 2),
|
||||
);
|
||||
}
|
||||
|
||||
createFile(fileName: string, content: string) {
|
||||
const filePath = join(this.testDir!, fileName);
|
||||
writeFileSync(filePath, content);
|
||||
|
||||
Reference in New Issue
Block a user