|
1 | 1 | // Test Install Sh Docker tests cover test install sh docker script behavior. |
2 | 2 | import { spawn, spawnSync } from "node:child_process"; |
3 | | -import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | +import { |
| 4 | +existsSync, |
| 5 | +mkdirSync, |
| 6 | +mkdtempSync, |
| 7 | +readFileSync, |
| 8 | +rmSync, |
| 9 | +writeFileSync, |
| 10 | +} from "node:fs"; |
4 | 11 | import { tmpdir } from "node:os"; |
5 | 12 | import path, { join } from "node:path"; |
6 | 13 | import { runInNewContext } from "node:vm"; |
@@ -322,6 +329,62 @@ describe("test-install-sh-docker", () => {
|
322 | 329 | expect(nonrootDockerfile).toContain("NPM_CONFIG_UPDATE_NOTIFIER=false"); |
323 | 330 | }); |
324 | 331 | |
| 332 | +it("keeps shared install helpers parsing and verifying installed CLI versions", () => { |
| 333 | +const root = tempDirs.make("openclaw-install-helper-"); |
| 334 | +const binDir = join(root, "bin"); |
| 335 | +mkdirSync(binDir, { recursive: true }); |
| 336 | +writeFileSync( |
| 337 | +join(binDir, "openclaw"), |
| 338 | +[ |
| 339 | +"#!/usr/bin/env bash", |
| 340 | +"set -euo pipefail", |
| 341 | +'case "${1:-}" in', |
| 342 | +" --version)", |
| 343 | +" printf 'OpenClaw v2026.6.21-beta.1\\r\\n'", |
| 344 | +" ;;", |
| 345 | +" --help)", |
| 346 | +" printf 'usage\\n'", |
| 347 | +" ;;", |
| 348 | +" *)", |
| 349 | +" exit 2", |
| 350 | +" ;;", |
| 351 | +"esac", |
| 352 | +"", |
| 353 | +].join("\n"), |
| 354 | +{ mode: 0o755 }, |
| 355 | +); |
| 356 | + |
| 357 | +const result = spawnSync( |
| 358 | +"bash", |
| 359 | +[ |
| 360 | +"-c", |
| 361 | +[ |
| 362 | +"set -euo pipefail", |
| 363 | +"source scripts/docker/install-sh-common/cli-verify.sh", |
| 364 | +"printf 'parsed=%s\\n' \"$(extract_openclaw_semver 'OpenClaw v2026.6.21-beta.1+build.7')\"", |
| 365 | +"verify_installed_cli openclaw 2026.6.21-beta.1", |
| 366 | +].join("\n"), |
| 367 | +], |
| 368 | +{ |
| 369 | +cwd: process.cwd(), |
| 370 | +encoding: "utf8", |
| 371 | +env: { |
| 372 | + ...process.env, |
| 373 | +HOME: root, |
| 374 | +PATH: `${binDir}${path.delimiter}${process.env.PATH ?? ""}`, |
| 375 | +}, |
| 376 | +}, |
| 377 | +); |
| 378 | + |
| 379 | +expect(result.status).toBe(0); |
| 380 | +expect(result.stderr).toBe(""); |
| 381 | +expect(result.stdout).toContain("parsed=2026.6.21-beta.1+build.7"); |
| 382 | +expect(result.stdout).toContain( |
| 383 | +"cli=openclaw installed=2026.6.21-beta.1 expected=2026.6.21-beta.1", |
| 384 | +); |
| 385 | +expect(result.stdout).toContain("==> Sanity: CLI runs"); |
| 386 | +}); |
| 387 | + |
325 | 388 | it("can reuse dist from the already-built root Docker smoke image", () => { |
326 | 389 | const script = readFileSync(SCRIPT_PATH, "utf8"); |
327 | 390 | const dockerfile = readFileSync("Dockerfile", "utf8"); |
|