





















@@ -0,0 +1,70 @@
1+import { spawnSync } from "node:child_process";
2+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3+import { tmpdir } from "node:os";
4+import path from "node:path";
5+import { describe, expect, it } from "vitest";
6+7+const ASSERTIONS_SCRIPT = "scripts/e2e/lib/release-scenarios/assertions.mjs";
8+9+function writeJson(filePath: string, value: unknown) {
10+mkdirSync(path.dirname(filePath), { recursive: true });
11+writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
12+}
13+14+function runAssertion(args: string[]) {
15+return spawnSync(process.execPath, [ASSERTIONS_SCRIPT, ...args], {
16+encoding: "utf8",
17+});
18+}
19+20+describe("release scenario assertions", () => {
21+it("passes when the installed package version matches the candidate version", () => {
22+const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-scenarios-"));
23+const packageRoot = path.join(root, "openclaw");
24+25+try {
26+writeJson(path.join(packageRoot, "package.json"), {
27+name: "openclaw",
28+version: "2026.5.26",
29+});
30+31+const result = runAssertion([
32+"assert-package-version",
33+packageRoot,
34+"2026.5.26",
35+"candidate",
36+]);
37+38+expect(result.status).toBe(0);
39+expect(result.stderr).toBe("");
40+} finally {
41+rmSync(root, { force: true, recursive: true });
42+}
43+});
44+45+it("fails when the global install still points at the baseline version", () => {
46+const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-scenarios-"));
47+const packageRoot = path.join(root, "openclaw");
48+49+try {
50+writeJson(path.join(packageRoot, "package.json"), {
51+name: "openclaw",
52+version: "2026.5.22",
53+});
54+55+const result = runAssertion([
56+"assert-package-version",
57+packageRoot,
58+"2026.5.26",
59+"candidate",
60+]);
61+62+expect(result.status).not.toBe(0);
63+expect(result.stderr).toContain(
64+"candidate package version mismatch: expected 2026.5.26, got 2026.5.22",
65+);
66+} finally {
67+rmSync(root, { force: true, recursive: true });
68+}
69+});
70+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。