mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
test(cleanup): fix temporary directory leaks in test suites (#26217)
This commit is contained in:
@@ -93,6 +93,25 @@ export async function createTmpDir(
|
||||
* Cleans up (deletes) a temporary directory and its contents.
|
||||
* @param dir The absolute path to the temporary directory to clean up.
|
||||
*/
|
||||
export async function cleanupTmpDir(dir: string) {
|
||||
await fs.rm(dir, { recursive: true, force: true });
|
||||
export async function cleanupTmpDir(dir: string | undefined) {
|
||||
if (!dir) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const exists = await fs
|
||||
.access(dir)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
|
||||
if (exists) {
|
||||
if (process.platform === 'win32') {
|
||||
// Give Windows a moment to release file handles
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
await fs.rm(dir, { recursive: true, force: true });
|
||||
}
|
||||
} catch {
|
||||
// Ignore errors during cleanup (e.g., directory already deleted)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user