





















@@ -0,0 +1,54 @@
1+import { execFileSync, spawnSync } from "node:child_process";
2+import path from "node:path";
3+import { describe, expect, it } from "vitest";
4+5+const helperPath = path.resolve("scripts/lib/openclaw-e2e-instance.sh");
6+7+function shellQuote(value: string): string {
8+return `'${value.replace(/'/gu, `'\\''`)}'`;
9+}
10+11+function runHelper(payload: string) {
12+return spawnSync(
13+"bash",
14+[
15+"-lc",
16+[
17+"set -euo pipefail",
18+`source ${shellQuote(helperPath)}`,
19+`openclaw_e2e_eval_test_state_from_b64 ${shellQuote(payload)}`,
20+'printf "value=%s" "${OPENCLAW_E2E_INSTANCE_TEST:-unset}"',
21+].join("; "),
22+],
23+{ encoding: "utf8" },
24+);
25+}
26+27+function base64(script: string): string {
28+return execFileSync("base64", { input: script, encoding: "utf8" }).replace(/\s+/gu, "");
29+}
30+31+describe("scripts/lib/openclaw-e2e-instance.sh", () => {
32+it("sources decoded test-state scripts", () => {
33+const result = runHelper(base64('export OPENCLAW_E2E_INSTANCE_TEST="ok"\n'));
34+35+expect(result.status).toBe(0);
36+expect(result.stdout).toBe("value=ok");
37+});
38+39+it("fails when the test-state payload is not valid base64", () => {
40+const result = runHelper("@@@");
41+42+expect(result.status).not.toBe(0);
43+expect(result.stdout).not.toContain("value=");
44+expect(result.stderr).toContain("Invalid OpenClaw test-state base64 payload");
45+});
46+47+it("fails when the test-state payload decodes to an empty script", () => {
48+const result = runHelper(base64("\n"));
49+50+expect(result.status).not.toBe(0);
51+expect(result.stdout).not.toContain("value=");
52+expect(result.stderr).toContain("decoded to an empty script");
53+});
54+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。