fix: stabilize windows cli tests

This commit is contained in:
Peter Steinberger
2026-01-19 14:44:17 +00:00
parent ef352d4dc6
commit 5df58e404f
3 changed files with 5 additions and 7 deletions

View File

@@ -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 });

View File

@@ -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);

View File

@@ -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);