





















@@ -6,26 +6,7 @@ import { cleanupTempDirs, makeTempDir } from "../test/helpers/temp-dir.js";
6677const tempRoots: string[] = [];
889-function withFakeCli(versionOutput: string): { root: string; cliPath: string } {
10-const root = makeTempDir(tempRoots, "openclaw-install-sh-");
11-const cliPath = path.join(root, "openclaw");
12-const escapedOutput = versionOutput.replace(/'/g, "'\\''");
13-fs.writeFileSync(
14-cliPath,
15-`#!/bin/sh
16-printf '%s\n' '${escapedOutput}'
17-`,
18-"utf-8",
19-);
20-fs.chmodSync(cliPath, 0o755);
21-return { root, cliPath };
22-}
23-24-function resolveInstallerVersionCases(params: {
25-cliPaths: string[];
26-stdinCliPath: string;
27-stdinCwd: string;
28-}): string[] {
9+function resolveInstallerVersionCases(params: { stdinCwd: string }): string[] {
2910const installerPath = path.join(process.cwd(), "scripts", "install.sh");
3011const installerSource = fs.readFileSync(installerPath, "utf-8");
3112const versionHelperStart = installerSource.indexOf("load_install_version_helpers() {");
@@ -39,22 +20,21 @@ function resolveInstallerVersionCases(params: {
3920[
4021"-c",
4122`${versionHelperSource}
42-for openclaw_bin in "\${@:3}"; do
43- OPENCLAW_BIN="$openclaw_bin"
44- resolve_openclaw_version
45-done
23+fake_openclaw_decorated() { printf '%s\\n' 'OpenClaw 2026.3.10 (abcdef0)'; }
24+fake_openclaw_raw() { printf '%s\\n' "OpenClaw dev's build"; }
25+OPENCLAW_BIN=fake_openclaw_decorated resolve_openclaw_version
26+OPENCLAW_BIN=fake_openclaw_raw resolve_openclaw_version
4627(
47- cd "$2"
48- FAKE_OPENCLAW_BIN="\${@:1:1}" bash -s <<'OPENCLAW_STDIN_INSTALLER'
28+ cd "$1"
29+ bash -s <<'OPENCLAW_STDIN_INSTALLER'
4930${versionHelperSource}
50-OPENCLAW_BIN="$FAKE_OPENCLAW_BIN"
31+fake_openclaw_stdin() { printf '%s\\n' 'OpenClaw 2026.3.10 (abcdef0)'; }
32+OPENCLAW_BIN=fake_openclaw_stdin
5133resolve_openclaw_version
5234OPENCLAW_STDIN_INSTALLER
5335)`,
5436"openclaw-version-test",
55-params.stdinCliPath,
5637params.stdinCwd,
57- ...params.cliPaths,
5838],
5939{
6040cwd: process.cwd(),
@@ -76,10 +56,6 @@ describe("install.sh version resolution", () => {
7656it.runIf(process.platform !== "win32")(
7757"parses CLI versions and keeps stdin helpers isolated from cwd",
7858() => {
79-const decorated = withFakeCli("OpenClaw 2026.3.10 (abcdef0)");
80-const raw = withFakeCli("OpenClaw dev's build");
81-const stdinFixture = withFakeCli("OpenClaw 2026.3.10 (abcdef0)");
82-8359const hostileCwd = makeTempDir(tempRoots, "openclaw-install-stdin-");
8460const hostileHelper = path.join(
8561hostileCwd,
@@ -100,8 +76,6 @@ extract_openclaw_semver() {
1007610177expect(
10278resolveInstallerVersionCases({
103-cliPaths: [decorated.cliPath, raw.cliPath],
104-stdinCliPath: stdinFixture.cliPath,
10579stdinCwd: hostileCwd,
10680}),
10781).toEqual(["2026.3.10", "OpenClaw dev's build", "2026.3.10"]);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。