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:
oldschoola
2026-06-23 15:21:27 -07:00
parent 93d730c01d
commit a2854ba768
204 changed files with 572 additions and 439 deletions
@@ -1,5 +1,4 @@
import { afterEach, describe, expect, it } from "bun:test";
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import type { AgentEvent } from "@oh-my-pi/pi-agent-core";
@@ -10,6 +9,7 @@ import type {
RpcHostToolCancelRequest,
RpcHostToolUpdate,
} from "@oh-my-pi/pi-coding-agent/modes/rpc/rpc-types";
import { removeWithRetries } from "@oh-my-pi/pi-utils";
const tempPaths: string[] = [];
@@ -17,7 +17,7 @@ afterEach(async () => {
await Promise.all(
tempPaths.splice(0).map(async filePath => {
try {
await fs.rm(filePath, { force: true });
await removeWithRetries(filePath);
} catch {}
}),
);