test(scripts): run kitchen sink bash tests on Windows

This commit is contained in:
Vincent Koc
2026-06-22 17:26:28 +08:00
parent 729de383bc
commit ceb69221ec
@@ -14,6 +14,7 @@ import path from "node:path";
import { describe, expect, it } from "vitest";
const ASSERTIONS_SCRIPT = "scripts/e2e/lib/kitchen-sink-plugin/assertions.mjs";
const BASH_BIN = process.platform === "win32" ? "bash" : "/bin/bash";
const SWEEP_SCRIPT = "scripts/e2e/lib/kitchen-sink-plugin/sweep.sh";
const REQUIRED_FULL_DIAGNOSTIC_CANARIES = [
"agent tool result middleware must be a function",
@@ -225,13 +226,42 @@ function runScanLogs({
}
function runSweepShell(script: string, env: NodeJS.ProcessEnv = {}) {
return spawnSync("/bin/bash", ["-c", script], {
return spawnSync(BASH_BIN, ["-c", toBashScript(script)], {
cwd: process.cwd(),
encoding: "utf8",
env: { ...process.env, ...env },
env: { ...process.env, ...toBashEnv(env) },
});
}
function toBashScript(script: string) {
if (process.platform === "win32") {
return `export PATH="/usr/bin:/bin:$PATH"\n${script}`;
}
return script;
}
function toBashEnv(env: NodeJS.ProcessEnv) {
if (process.platform !== "win32") {
return env;
}
return Object.fromEntries(
Object.entries(env).map(([key, value]) => [
key,
typeof value === "string" ? toGitBashPath(value) : value,
]),
);
}
function toGitBashPath(value: string) {
const match = /^([A-Za-z]):[\\/](.*)$/u.exec(value);
if (!match) {
return value;
}
return `/${match[1].toLowerCase()}/${match[2].replaceAll("\\", "/")}`;
}
describe("kitchen-sink plugin assertions", () => {
it("bounds expected-failure output before matching failure diagnostics", () => {
const scratchRoot = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-sink-failure-cap-"));