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