Skip to content

Commit 9ccc8fc

Browse files
authored
test(infra): run Windows path regressions cross-platform (#116627)
1 parent c3bb8fc commit 9ccc8fc

2 files changed

Lines changed: 33 additions & 36 deletions

File tree

‎src/infra/exec-command-resolution.test.ts‎

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import fs from "node:fs";
33
import path from "node:path";
44
import { describe, expect, it } from "vitest";
5+
import { withMockedPlatform } from "../test-utils/vitest-spies.js";
56
import { makeExecutable, makePathEnv, makeTempDir } from "./exec-approvals-test-helpers.js";
67
import {
78
evaluateExecAllowlist,
@@ -562,27 +563,25 @@ describe("exec-command-resolution", () => {
562563
});
563564

564565
it("does not synthesize cwd-joined allowlist candidates from drive-less windows roots", () => {
565-
if (process.platform !== "win32") {
566-
return;
567-
}
568-
569-
expect(
570-
resolveAllowlistCandidatePath(
571-
{
572-
rawExecutable: String.raw`:\Users\demo\AI\system\openclaw`,
573-
executableName: "openclaw",
574-
},
575-
String.raw`C:\Users\demo\AI\system\openclaw`,
576-
),
577-
).toBeUndefined();
578-
expect(
579-
resolveAllowlistCandidatePath(
580-
{
581-
rawExecutable: String.raw`:/Users/demo/AI/system/openclaw`,
582-
executableName: "openclaw",
583-
},
584-
String.raw`C:\Users\demo\AI\system\openclaw`,
585-
),
586-
).toBeUndefined();
566+
withMockedPlatform("win32", () => {
567+
expect(
568+
resolveAllowlistCandidatePath(
569+
{
570+
rawExecutable: String.raw`:\Users\demo\AI\system\openclaw`,
571+
executableName: "openclaw",
572+
},
573+
String.raw`C:\Users\demo\AI\system\openclaw`,
574+
),
575+
).toBeUndefined();
576+
expect(
577+
resolveAllowlistCandidatePath(
578+
{
579+
rawExecutable: String.raw`:/Users/demo/AI/system/openclaw`,
580+
executableName: "openclaw",
581+
},
582+
String.raw`C:\Users\demo\AI\system\openclaw`,
583+
),
584+
).toBeUndefined();
585+
});
587586
});
588587
});

‎src/infra/executable-path.test.ts‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,18 @@ describe("executable path helpers", () => {
195195
);
196196

197197
it("does not treat drive-less rooted windows paths as cwd-relative executables", () => {
198-
if (process.platform !== "win32") {
199-
return;
200-
}
201-
202-
expect(
203-
resolveExecutablePath(String.raw`:\Users\demo\AI\system\openclaw\git.exe`, {
204-
cwd: String.raw`C:\Users\demo\AI\system\openclaw`,
205-
}),
206-
).toBeUndefined();
207-
expect(
208-
resolveExecutablePath(String.raw`:/Users/demo/AI/system/openclaw/git.exe`, {
209-
cwd: String.raw`C:\Users\demo\AI\system\openclaw`,
210-
}),
211-
).toBeUndefined();
198+
withMockedPlatform("win32", () => {
199+
expect(
200+
resolveExecutablePath(String.raw`:\Users\demo\AI\system\openclaw\git.exe`, {
201+
cwd: String.raw`C:\Users\demo\AI\system\openclaw`,
202+
}),
203+
).toBeUndefined();
204+
expect(
205+
resolveExecutablePath(String.raw`:/Users/demo/AI/system/openclaw/git.exe`, {
206+
cwd: String.raw`C:\Users\demo\AI\system\openclaw`,
207+
}),
208+
).toBeUndefined();
209+
});
212210
});
213211
});
214212

0 commit comments

Comments
 (0)