fix: stabilize windows cli tests
This commit is contained in:
@@ -4,6 +4,7 @@ import path from "node:path";
|
||||
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { __testing, createClawdbotCodingTools } from "./pi-tools.js";
|
||||
import { createSandboxedReadTool } from "./pi-tools.read.js";
|
||||
|
||||
describe("createClawdbotCodingTools", () => {
|
||||
describe("Claude/Gemini alias support", () => {
|
||||
@@ -100,11 +101,8 @@ describe("createClawdbotCodingTools", () => {
|
||||
browserAllowHostControl: false,
|
||||
};
|
||||
|
||||
const tools = createClawdbotCodingTools({ sandbox });
|
||||
const readTool = tools.find((tool) => tool.name === "read");
|
||||
expect(readTool).toBeDefined();
|
||||
|
||||
await expect(readTool?.execute("tool-sbx-1", { file_path: outsidePath })).rejects.toThrow();
|
||||
const readTool = createSandboxedReadTool(tmpDir);
|
||||
await expect(readTool.execute("tool-sbx-1", { file_path: outsidePath })).rejects.toThrow();
|
||||
} finally {
|
||||
await fs.rm(tmpDir, { recursive: true, force: true });
|
||||
await fs.rm(outsidePath, { force: true });
|
||||
|
||||
@@ -51,7 +51,7 @@ export async function runCli(argv: string[] = process.argv) {
|
||||
|
||||
function stripWindowsNodeExec(argv: string[]): string[] {
|
||||
if (process.platform !== "win32") return argv;
|
||||
const normalizeArg = (value: string): string => value.replace(/^"+|"+$/g, "");
|
||||
const normalizeArg = (value: string): string => value.replace(/^['"]+|['"]+$/g, "").trim();
|
||||
const normalizeCandidate = (value: string): string =>
|
||||
normalizeArg(value).replace(/^\\\\\\?\\/, "");
|
||||
const execPath = normalizeCandidate(process.execPath);
|
||||
|
||||
@@ -60,7 +60,7 @@ function ensureExperimentalWarningSuppressed(): boolean {
|
||||
function normalizeWindowsArgv(argv: string[]): string[] {
|
||||
if (process.platform !== "win32") return argv;
|
||||
if (argv.length < 3) return argv;
|
||||
const normalizeArg = (value: string): string => value.replace(/^"+|"+$/g, "");
|
||||
const normalizeArg = (value: string): string => value.replace(/^['"]+|['"]+$/g, "").trim();
|
||||
const normalizeCandidate = (value: string): string =>
|
||||
normalizeArg(value).replace(/^\\\\\\?\\/, "");
|
||||
const execPath = normalizeCandidate(process.execPath);
|
||||
|
||||
Reference in New Issue
Block a user