test(infra): run Windows path regressions cross-platform (#116627)

This commit is contained in:
Vincent Koc
2026-07-31 10:33:51 +08:00
committed by GitHub
parent c3bb8fc265
commit 9ccc8fcc27
2 changed files with 33 additions and 36 deletions
+21 -22
View File
@@ -2,6 +2,7 @@
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { withMockedPlatform } from "../test-utils/vitest-spies.js";
import { makeExecutable, makePathEnv, makeTempDir } from "./exec-approvals-test-helpers.js";
import {
evaluateExecAllowlist,
@@ -562,27 +563,25 @@ describe("exec-command-resolution", () => {
});
it("does not synthesize cwd-joined allowlist candidates from drive-less windows roots", () => {
if (process.platform !== "win32") {
return;
}
expect(
resolveAllowlistCandidatePath(
{
rawExecutable: String.raw`:\Users\demo\AI\system\openclaw`,
executableName: "openclaw",
},
String.raw`C:\Users\demo\AI\system\openclaw`,
),
).toBeUndefined();
expect(
resolveAllowlistCandidatePath(
{
rawExecutable: String.raw`:/Users/demo/AI/system/openclaw`,
executableName: "openclaw",
},
String.raw`C:\Users\demo\AI\system\openclaw`,
),
).toBeUndefined();
withMockedPlatform("win32", () => {
expect(
resolveAllowlistCandidatePath(
{
rawExecutable: String.raw`:\Users\demo\AI\system\openclaw`,
executableName: "openclaw",
},
String.raw`C:\Users\demo\AI\system\openclaw`,
),
).toBeUndefined();
expect(
resolveAllowlistCandidatePath(
{
rawExecutable: String.raw`:/Users/demo/AI/system/openclaw`,
executableName: "openclaw",
},
String.raw`C:\Users\demo\AI\system\openclaw`,
),
).toBeUndefined();
});
});
});
+12 -14
View File
@@ -195,20 +195,18 @@ describe("executable path helpers", () => {
);
it("does not treat drive-less rooted windows paths as cwd-relative executables", () => {
if (process.platform !== "win32") {
return;
}
expect(
resolveExecutablePath(String.raw`:\Users\demo\AI\system\openclaw\git.exe`, {
cwd: String.raw`C:\Users\demo\AI\system\openclaw`,
}),
).toBeUndefined();
expect(
resolveExecutablePath(String.raw`:/Users/demo/AI/system/openclaw/git.exe`, {
cwd: String.raw`C:\Users\demo\AI\system\openclaw`,
}),
).toBeUndefined();
withMockedPlatform("win32", () => {
expect(
resolveExecutablePath(String.raw`:\Users\demo\AI\system\openclaw\git.exe`, {
cwd: String.raw`C:\Users\demo\AI\system\openclaw`,
}),
).toBeUndefined();
expect(
resolveExecutablePath(String.raw`:/Users/demo/AI/system/openclaw/git.exe`, {
cwd: String.raw`C:\Users\demo\AI\system\openclaw`,
}),
).toBeUndefined();
});
});
});