@@ -14,6 +14,7 @@ import path from "node:path";
|
14 | 14 | import { describe, expect, it } from "vitest"; |
15 | 15 | |
16 | 16 | const ASSERTIONS_SCRIPT = "scripts/e2e/lib/kitchen-sink-plugin/assertions.mjs"; |
| 17 | +const BASH_BIN = process.platform === "win32" ? "bash" : "/bin/bash"; |
17 | 18 | const SWEEP_SCRIPT = "scripts/e2e/lib/kitchen-sink-plugin/sweep.sh"; |
18 | 19 | const REQUIRED_FULL_DIAGNOSTIC_CANARIES = [ |
19 | 20 | "agent tool result middleware must be a function", |
@@ -225,13 +226,42 @@ function runScanLogs({
|
225 | 226 | } |
226 | 227 | |
227 | 228 | function runSweepShell(script: string, env: NodeJS.ProcessEnv = {}) { |
228 | | -return spawnSync("/bin/bash", ["-c", script], { |
| 229 | +return spawnSync(BASH_BIN, ["-c", toBashScript(script)], { |
229 | 230 | cwd: process.cwd(), |
230 | 231 | encoding: "utf8", |
231 | | -env: { ...process.env, ...env }, |
| 232 | +env: { ...process.env, ...toBashEnv(env) }, |
232 | 233 | }); |
233 | 234 | } |
234 | 235 | |
| 236 | +function toBashScript(script: string) { |
| 237 | +if (process.platform === "win32") { |
| 238 | +return `export PATH="/usr/bin:/bin:$PATH"\n${script}`; |
| 239 | +} |
| 240 | +return script; |
| 241 | +} |
| 242 | + |
| 243 | +function toBashEnv(env: NodeJS.ProcessEnv) { |
| 244 | +if (process.platform !== "win32") { |
| 245 | +return env; |
| 246 | +} |
| 247 | + |
| 248 | +return Object.fromEntries( |
| 249 | +Object.entries(env).map(([key, value]) => [ |
| 250 | +key, |
| 251 | +typeof value === "string" ? toGitBashPath(value) : value, |
| 252 | +]), |
| 253 | +); |
| 254 | +} |
| 255 | + |
| 256 | +function toGitBashPath(value: string) { |
| 257 | +const match = /^([A-Za-z]):[\\/](.*)$/u.exec(value); |
| 258 | +if (!match) { |
| 259 | +return value; |
| 260 | +} |
| 261 | + |
| 262 | +return `/${match[1].toLowerCase()}/${match[2].replaceAll("\\", "/")}`; |
| 263 | +} |
| 264 | + |
235 | 265 | describe("kitchen-sink plugin assertions", () => { |
236 | 266 | it("bounds expected-failure output before matching failure diagnostics", () => { |
237 | 267 | const scratchRoot = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-sink-failure-cap-")); |
|