mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 05:55:17 -07:00
fix(infra) - Make list dir less flaky (#12554)
Co-authored-by: gemini-cli-robot <gemini-cli-robot@google.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it } from 'vitest';
|
||||||
import {
|
import {
|
||||||
TestRig,
|
TestRig,
|
||||||
poll,
|
poll,
|
||||||
@@ -17,7 +17,7 @@ import { join } from 'node:path';
|
|||||||
describe('list_directory', () => {
|
describe('list_directory', () => {
|
||||||
it('should be able to list a directory', async () => {
|
it('should be able to list a directory', async () => {
|
||||||
const rig = new TestRig();
|
const rig = new TestRig();
|
||||||
await rig.setup('should be able to list a directory');
|
rig.setup('should be able to list a directory');
|
||||||
rig.createFile('file1.txt', 'file 1 content');
|
rig.createFile('file1.txt', 'file 1 content');
|
||||||
rig.mkdir('subdir');
|
rig.mkdir('subdir');
|
||||||
rig.sync();
|
rig.sync();
|
||||||
@@ -38,33 +38,27 @@ describe('list_directory', () => {
|
|||||||
|
|
||||||
const result = await rig.run(prompt);
|
const result = await rig.run(prompt);
|
||||||
|
|
||||||
const foundToolCall = await rig.waitForToolCall('list_directory');
|
try {
|
||||||
|
await rig.expectToolCallSuccess(['list_directory']);
|
||||||
|
} catch (e) {
|
||||||
|
// Add debugging information
|
||||||
|
if (!result.includes('file1.txt') || !result.includes('subdir')) {
|
||||||
|
const allTools = printDebugInfo(rig, result, {
|
||||||
|
'Found tool call': false,
|
||||||
|
'Contains file1.txt': result.includes('file1.txt'),
|
||||||
|
'Contains subdir': result.includes('subdir'),
|
||||||
|
});
|
||||||
|
|
||||||
// Add debugging information
|
console.error(
|
||||||
if (
|
'List directory calls:',
|
||||||
!foundToolCall ||
|
allTools
|
||||||
!result.includes('file1.txt') ||
|
.filter((t) => t.toolRequest.name === 'list_directory')
|
||||||
!result.includes('subdir')
|
.map((t) => t.toolRequest.args),
|
||||||
) {
|
);
|
||||||
const allTools = printDebugInfo(rig, result, {
|
}
|
||||||
'Found tool call': foundToolCall,
|
throw e;
|
||||||
'Contains file1.txt': result.includes('file1.txt'),
|
|
||||||
'Contains subdir': result.includes('subdir'),
|
|
||||||
});
|
|
||||||
|
|
||||||
console.error(
|
|
||||||
'List directory calls:',
|
|
||||||
allTools
|
|
||||||
.filter((t) => t.toolRequest.name === 'list_directory')
|
|
||||||
.map((t) => t.toolRequest.args),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(
|
|
||||||
foundToolCall,
|
|
||||||
'Expected to find a list_directory tool call',
|
|
||||||
).toBeTruthy();
|
|
||||||
|
|
||||||
// Validate model output - will throw if no output, warn if missing expected content
|
// Validate model output - will throw if no output, warn if missing expected content
|
||||||
validateModelOutput(result, ['file1.txt', 'subdir'], 'List directory test');
|
validateModelOutput(result, ['file1.txt', 'subdir'], 'List directory test');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user