mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 03:24:42 -07:00
fix(tests): improve test reliability and performance (#8395)
This commit is contained in:
@@ -63,7 +63,13 @@ describe('loadServerHierarchicalMemory', () => {
|
||||
// Some tests set this to a different value.
|
||||
setGeminiMdFilename(DEFAULT_CONTEXT_FILENAME);
|
||||
// Clean up the temporary directory to prevent resource leaks.
|
||||
await fsPromises.rm(testRootDir, { recursive: true, force: true });
|
||||
// Use maxRetries option for robust cleanup without race conditions
|
||||
await fsPromises.rm(testRootDir, {
|
||||
recursive: true,
|
||||
force: true,
|
||||
maxRetries: 3,
|
||||
retryDelay: 10,
|
||||
});
|
||||
});
|
||||
|
||||
describe('when untrusted', () => {
|
||||
@@ -354,9 +360,11 @@ describe('loadServerHierarchicalMemory', () => {
|
||||
.spyOn(console, 'debug')
|
||||
.mockImplementation(() => {});
|
||||
|
||||
for (let i = 0; i < 100; i++) {
|
||||
await createEmptyDir(path.join(cwd, `deep_dir_${i}`));
|
||||
}
|
||||
// Create directories in parallel for better performance
|
||||
const dirPromises = Array.from({ length: 2 }, (_, i) =>
|
||||
createEmptyDir(path.join(cwd, `deep_dir_${i}`)),
|
||||
);
|
||||
await Promise.all(dirPromises);
|
||||
|
||||
// Pass the custom limit directly to the function
|
||||
await loadServerHierarchicalMemory(
|
||||
@@ -371,12 +379,12 @@ describe('loadServerHierarchicalMemory', () => {
|
||||
respectGitIgnore: true,
|
||||
respectGeminiIgnore: true,
|
||||
},
|
||||
50, // maxDirs
|
||||
1, // maxDirs
|
||||
);
|
||||
|
||||
expect(consoleDebugSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('[DEBUG] [BfsFileSearch]'),
|
||||
expect.stringContaining('Scanning [50/50]:'),
|
||||
expect.stringContaining('Scanning [1/1]:'),
|
||||
);
|
||||
|
||||
vi.mocked(console.debug).mockRestore();
|
||||
|
||||
Reference in New Issue
Block a user