test(cleanup): fix temporary directory leaks in test suites (#26217)

This commit is contained in:
Adib234
2026-05-04 15:08:02 -04:00
committed by GitHub
parent a7beb890d0
commit 75a8de83fc
4 changed files with 50 additions and 11 deletions
@@ -20,8 +20,11 @@ import {
getScopedEnvContents,
type ExtensionSetting,
} from '../../config/extensions/extensionSettings.js';
import { cleanupTmpDir } from '@google/gemini-cli-test-utils';
import prompts from 'prompts';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
const { mockExtensionManager, mockGetExtensionManager, mockLoadSettings } =
vi.hoisted(() => {
@@ -84,7 +87,9 @@ describe('extensions configure command', () => {
vi.spyOn(debugLogger, 'error');
vi.clearAllMocks();
tempWorkspaceDir = fs.mkdtempSync('gemini-cli-test-workspace');
tempWorkspaceDir = fs.mkdtempSync(
path.join(os.tmpdir(), 'gemini-cli-test-workspace-'),
);
vi.spyOn(process, 'cwd').mockReturnValue(tempWorkspaceDir);
// Default behaviors
mockLoadSettings.mockReturnValue({ merged: {} });
@@ -94,7 +99,8 @@ describe('extensions configure command', () => {
);
});
afterEach(() => {
afterEach(async () => {
await cleanupTmpDir(tempWorkspaceDir);
vi.restoreAllMocks();
});