fix: migrate coding-agent tests from fs.rm to removeWithRetries
Migrate 203 test files (356 call sites) from fs.rm/fs.rmSync to
removeWithRetries/removeSyncWithRetries to reduce EBUSY test failures
on Windows. removeWithRetries is now exported from @oh-my-pi/pi-utils.
The migration uses a regex-based approach that:
- Replaces fs.rm(path, { recursive, force }) → removeWithRetries(path)
- Replaces fs.rmSync(path, { recursive, force }) → removeSyncWithRetries(path)
- Replaces fs.rm(path) → removeWithRetries(path) (no options)
- Skips fs.rm/fs.rmSync inside template literals (bun --eval scripts)
- Adds imports to existing @oh-my-pi/pi-utils import or creates new one
- Removes unused fs imports where fs.rm was the only fs usage (4 files)
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
type TtsrTestArgs,
|
||||
} from "@oh-my-pi/pi-coding-agent/cli/ttsr-cli";
|
||||
import { resetSettingsForTest } from "@oh-my-pi/pi-coding-agent/config/settings";
|
||||
import { getProjectAgentDir, getProjectDir, setProjectDir } from "@oh-my-pi/pi-utils";
|
||||
import { getProjectAgentDir, getProjectDir, removeSyncWithRetries, setProjectDir } from "@oh-my-pi/pi-utils";
|
||||
|
||||
let testTmpDir: string;
|
||||
|
||||
@@ -20,7 +20,7 @@ beforeAll(() => {
|
||||
|
||||
afterAll(() => {
|
||||
if (testTmpDir && fs.existsSync(testTmpDir)) {
|
||||
fs.rmSync(testTmpDir, { force: true, recursive: true });
|
||||
removeSyncWithRetries(testTmpDir);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -92,7 +92,7 @@ async function writeTempSnippet(content: string, ext: string): Promise<string> {
|
||||
function cleanupTmp(): void {
|
||||
if (!testTmpDir || !fs.existsSync(testTmpDir)) return;
|
||||
for (const entry of fs.readdirSync(testTmpDir)) {
|
||||
fs.rmSync(path.join(testTmpDir, entry), { force: true, recursive: true });
|
||||
removeSyncWithRetries(path.join(testTmpDir, entry));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user