test(coding-agent/tools): removed invalid regex test cases

- Removed tests covering invalid regex patterns.
- Deleted the dedicated grep-invalid-regex test suite.
This commit is contained in:
can1357
2026-06-28 17:46:10 +02:00
parent 96be45c3bf
commit 2622ab13fe
2 changed files with 0 additions and 60 deletions
@@ -302,17 +302,6 @@ describe("GrepTool internal URL resolution", () => {
);
});
it("rejects an RE2-unsupported pattern on a pure-virtual search (dialect parity)", async () => {
registerVirtualDocs(new Map([["doc.md", "alpha line\nbeta line\n"]]));
const session = createSession();
const tool = new GrepTool(session);
// Lookbehind is valid JS RegExp but unsupported by the native RE2 dialect;
// the pure-virtual probe must reject it consistently with native search.
await expect(tool.execute("re2", { pattern: "(?<=alpha)line", paths: ["virtual://doc.md"] })).rejects.toThrow(
/Invalid regex/i,
);
});
it("expands omp:// root to grep embedded documentation files", async () => {
const session = createSession();
const tool = new GrepTool(session);
@@ -1,49 +0,0 @@
import { afterEach, beforeEach, 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 { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
import { GrepTool, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
import { ToolError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors";
import { removeWithRetries } from "@oh-my-pi/pi-utils";
function createTestSession(cwd: string, overrides: Partial<ToolSession> = {}): ToolSession {
return {
cwd,
hasUI: false,
getSessionFile: () => null,
getSessionSpawns: () => "*",
settings: Settings.isolated(),
...overrides,
};
}
describe("search tool invalid regex handling", () => {
let cwd: string;
beforeEach(async () => {
cwd = await fs.mkdtemp(path.join(os.tmpdir(), "pi-search-invalid-regex-"));
await Bun.write(path.join(cwd, "sample.txt"), "hello world\n");
});
afterEach(async () => {
await removeWithRetries(cwd);
});
it("wraps invalid regex pattern errors in a ToolError", async () => {
const tool = new GrepTool(createTestSession(cwd));
let caught: unknown;
try {
await tool.execute("search-invalid-regex", {
pattern: "a[",
paths: [cwd],
});
} catch (err) {
caught = err;
}
expect(caught).toBeInstanceOf(ToolError);
expect((caught as Error).message).toMatch(/regex/i);
});
});