Merge PR #3354: fix: migrate coding-agent tests to removeWithRetries (@oldschoola)
This commit is contained in:
@@ -3,8 +3,8 @@ import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import * as url from "node:url";
|
||||
|
||||
import * as git from "@oh-my-pi/pi-coding-agent/utils/git";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
|
||||
// Regression coverage for #1589: `git.clone({ sha })` used to hardcode
|
||||
// `--depth 1`, producing a shallow clone whose object store never contained
|
||||
@@ -56,7 +56,7 @@ describe("git.clone with options.sha", () => {
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await fs.rm(tmpRoot, { recursive: true, force: true });
|
||||
await removeWithRetries(tmpRoot);
|
||||
});
|
||||
|
||||
test("checks out a non-tip SHA (regression for #1589)", async () => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { $ } from "bun";
|
||||
import * as git from "../../src/utils/git";
|
||||
|
||||
@@ -41,7 +42,7 @@ describe("git reference directory fallback", () => {
|
||||
expect(packedRefs).toContain("refs/heads/pi-flash");
|
||||
|
||||
// Delete the loose ref file for refs/heads/pi-flash if git pack-refs didn't already delete it (it usually does).
|
||||
await fs.rm(path.join(repoDir, ".git", "refs", "heads", "pi-flash"), { force: true });
|
||||
await removeWithRetries(path.join(repoDir, ".git", "refs", "heads", "pi-flash"));
|
||||
|
||||
// Now, create refs/heads/pi-flash as a directory to simulate another branch like "pi-flash/feature" existing.
|
||||
// We can just create the directory and a file inside it, or just the directory.
|
||||
@@ -50,7 +51,7 @@ describe("git reference directory fallback", () => {
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await fs.rm(repoDir, { recursive: true, force: true }).catch(() => {});
|
||||
await removeWithRetries(repoDir).catch(() => {});
|
||||
});
|
||||
|
||||
test("resolves branch that has directory conflict via resolveSync on head", () => {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
type DescribeAttachedImagesDeps,
|
||||
describeAttachedImagesForTextModel,
|
||||
} from "@oh-my-pi/pi-coding-agent/utils/image-vision-fallback";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
|
||||
// 1x1 transparent PNG.
|
||||
const TINY_PNG_BASE64 =
|
||||
@@ -82,7 +83,7 @@ describe("describeAttachedImagesForTextModel", () => {
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await fs.rm(testDir, { recursive: true, force: true });
|
||||
await removeWithRetries(testDir);
|
||||
});
|
||||
|
||||
it("saves the image under local:// and injects a vision description block", async () => {
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import * as jj from "@oh-my-pi/pi-coding-agent/utils/jj";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
|
||||
describe("jj workspace detection", () => {
|
||||
let tmpDir: string | undefined;
|
||||
@@ -10,7 +11,7 @@ describe("jj workspace detection", () => {
|
||||
afterEach(async () => {
|
||||
jj.repo.clearRootCache();
|
||||
if (tmpDir) {
|
||||
await fs.rm(tmpDir, { recursive: true, force: true });
|
||||
await removeWithRetries(tmpDir);
|
||||
tmpDir = undefined;
|
||||
}
|
||||
});
|
||||
@@ -37,7 +38,7 @@ describe("jj workspace detection", () => {
|
||||
await fs.mkdir(nested, { recursive: true });
|
||||
|
||||
expect(await jj.repo.root(nested)).toBe(dir);
|
||||
await fs.rm(path.join(dir, ".jj"), { recursive: true, force: true });
|
||||
await removeWithRetries(path.join(dir, ".jj"));
|
||||
|
||||
expect(await jj.repo.root(nested)).toBe(dir);
|
||||
expect(await jj.repo.root(path.join(dir, "src"))).toBeNull();
|
||||
@@ -83,7 +84,7 @@ describe("isPureJjRepo", () => {
|
||||
|
||||
afterEach(async () => {
|
||||
jj.repo.clearRootCache();
|
||||
await Promise.all(tempDirs.splice(0).map(dir => fs.rm(dir, { recursive: true, force: true })));
|
||||
await Promise.all(tempDirs.splice(0).map(dir => removeWithRetries(dir)));
|
||||
});
|
||||
|
||||
async function createTempDir(prefix: string): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user