Skip to content

Commit 086274f

Browse files
committed
test(e2e): exercise onboard wizard exit status
1 parent ed07a7a commit 086274f

2 files changed

Lines changed: 62 additions & 14 deletions

File tree

scripts/e2e/lib/onboard/scenario.sh

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ set -euo pipefail
33
trap "" PIPE
44
export TERM=xterm-256color
55
source scripts/lib/openclaw-e2e-instance.sh
6-
openclaw_e2e_eval_test_state_from_b64 "${OPENCLAW_TEST_STATE_FUNCTION_B64:?missing OPENCLAW_TEST_STATE_FUNCTION_B64}"
7-
ONBOARD_FLAGS="--flow quickstart --auth-choice skip --skip-channels --skip-skills --skip-daemon --skip-ui"
8-
OPENCLAW_ENTRY="$(openclaw_e2e_resolve_entrypoint)"
6+
OPENCLAW_ONBOARD_SCENARIO_SOURCE_ONLY="${OPENCLAW_ONBOARD_SCENARIO_SOURCE_ONLY:-0}"
7+
if [ "$OPENCLAW_ONBOARD_SCENARIO_SOURCE_ONLY" != "1" ]; then
8+
openclaw_e2e_eval_test_state_from_b64 "${OPENCLAW_TEST_STATE_FUNCTION_B64:?missing OPENCLAW_TEST_STATE_FUNCTION_B64}"
9+
fi
10+
ONBOARD_FLAGS="${ONBOARD_FLAGS:---flow quickstart --auth-choice skip --skip-channels --skip-skills --skip-daemon --skip-ui}"
11+
if [ -z "${OPENCLAW_ENTRY:-}" ] && [ "$OPENCLAW_ONBOARD_SCENARIO_SOURCE_ONLY" != "1" ]; then
12+
OPENCLAW_ENTRY="$(openclaw_e2e_resolve_entrypoint)"
13+
fi
914
export OPENCLAW_ENTRY
1015
ONBOARD_TMP_ROOT="${OPENCLAW_ONBOARD_E2E_TMPDIR:-${TMPDIR:-/tmp}}"
1116
ONBOARD_TMP_ROOT="${ONBOARD_TMP_ROOT%/}"
@@ -19,10 +24,14 @@ cleanup_onboard_artifacts() {
1924
openclaw_e2e_stop_process "${GATEWAY_PID:-}"
2025
rm -rf "$ONBOARD_TMP_DIR"
2126
}
22-
trap cleanup_onboard_artifacts EXIT
27+
if [ "$OPENCLAW_ONBOARD_SCENARIO_SOURCE_ONLY" != "1" ]; then
28+
trap cleanup_onboard_artifacts EXIT
29+
fi
2330

2431
# Provide a minimal trash shim to avoid noisy "missing trash" logs in containers.
25-
openclaw_e2e_install_trash_shim
32+
if [ "$OPENCLAW_ONBOARD_SCENARIO_SOURCE_ONLY" != "1" ]; then
33+
openclaw_e2e_install_trash_shim
34+
fi
2635

2736
send() {
2837
local payload="$1"
@@ -313,8 +322,10 @@ validate_local_basic_log() {
313322
openclaw_e2e_assert_log_not_contains "$log_path" "systemctl --user unavailable"
314323
}
315324

316-
run_case_local_basic
317-
run_case_remote_non_interactive
318-
run_case_reset
319-
run_case_channels
320-
run_case_skills
325+
if [ "$OPENCLAW_ONBOARD_SCENARIO_SOURCE_ONLY" != "1" ]; then
326+
run_case_local_basic
327+
run_case_remote_non_interactive
328+
run_case_reset
329+
run_case_channels
330+
run_case_skills
331+
fi

test/scripts/e2e-shell-tempfiles.test.ts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { readdir, readFile } from "node:fs/promises";
1+
import { spawnSync } from "node:child_process";
2+
import { mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
3+
import { tmpdir } from "node:os";
24
import path from "node:path";
35
import { describe, expect, it } from "vitest";
46

@@ -33,10 +35,45 @@ describe("e2e shell tempfile hygiene", () => {
3335
});
3436

3537
it("preserves wizard exit status when reporting failures", async () => {
36-
const contents = await readFile("scripts/e2e/lib/onboard/scenario.sh", "utf8");
38+
const tempRoot = await mkdtemp(path.join(tmpdir(), "openclaw-onboard-status-test-"));
39+
const fixturePath = path.join(tempRoot, "wizard-status.sh");
40+
await writeFile(
41+
fixturePath,
42+
`#!/usr/bin/env bash
43+
set -euo pipefail
44+
45+
export OPENCLAW_ONBOARD_SCENARIO_SOURCE_ONLY=1
46+
export OPENCLAW_ONBOARD_E2E_TMPDIR=${JSON.stringify(tempRoot)}
47+
OPENCLAW_ENTRY=node
48+
openclaw_test_state_create() { :; }
49+
source scripts/e2e/lib/onboard/scenario.sh
50+
51+
openclaw_e2e_run_script_with_pty() {
52+
local _command="$1"
53+
local log_path="$2"
54+
printf 'fake wizard log\\n' >"$log_path"
55+
exit 7
56+
}
57+
58+
send_noop() { :; }
3759
38-
expect(contents).not.toContain('if ! wait "$wizard_pid"');
39-
expect(contents).toContain('wait "$wizard_pid" || wizard_status=$?');
60+
run_wizard_cmd failing-wizard fake-state "node fake-wizard" send_noop false
61+
`,
62+
);
63+
64+
try {
65+
const result = spawnSync("bash", [fixturePath], {
66+
cwd: process.cwd(),
67+
encoding: "utf8",
68+
});
69+
const output = `${result.stdout}\n${result.stderr}`;
70+
71+
expect(result.status).toBe(7);
72+
expect(output).toContain("Wizard exited with status 7");
73+
expect(output).toContain("fake wizard log");
74+
} finally {
75+
await rm(tempRoot, { force: true, recursive: true });
76+
}
4077
});
4178

4279
it("checks local onboarding logs for systemd noise", async () => {

0 commit comments

Comments
 (0)