diff --git a/scripts/e2e/lib/kitchen-sink-plugin/sweep.sh b/scripts/e2e/lib/kitchen-sink-plugin/sweep.sh index 91f83ef7c24..49e0536faad 100644 --- a/scripts/e2e/lib/kitchen-sink-plugin/sweep.sh +++ b/scripts/e2e/lib/kitchen-sink-plugin/sweep.sh @@ -109,7 +109,8 @@ start_kitchen_sink_clawhub_fixture_server() { KITCHEN_SINK_CLAWHUB_FIXTURE_DIR="$fixture_dir" KITCHEN_SINK_CLAWHUB_PID_FILE="$server_pid_file" - local wait_attempts="${OPENCLAW_CLAWHUB_FIXTURE_WAIT_ATTEMPTS:-600}" + local wait_attempts + wait_attempts="$(openclaw_e2e_read_positive_int_env OPENCLAW_CLAWHUB_FIXTURE_WAIT_ATTEMPTS 600)" || return $? for _ in $(seq 1 "$wait_attempts"); do if [[ -s "$server_port_file" ]]; then export OPENCLAW_CLAWHUB_URL="http://127.0.0.1:$(cat "$server_port_file")" diff --git a/test/scripts/kitchen-sink-plugin-assertions.test.ts b/test/scripts/kitchen-sink-plugin-assertions.test.ts index b96b53d8d2f..0a54f86ef1e 100644 --- a/test/scripts/kitchen-sink-plugin-assertions.test.ts +++ b/test/scripts/kitchen-sink-plugin-assertions.test.ts @@ -717,6 +717,48 @@ test -d "$SCRATCH_ROOT" } }); + it("rejects invalid ClawHub fixture wait attempts before starting the server", () => { + const parent = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-sink-clawhub-attempts-")); + const fakeBin = path.join(parent, "bin"); + const scratchRoot = path.join(parent, "scratch"); + const fixtureDir = path.join(scratchRoot, "clawhub-fixture"); + const nodeShim = path.join(fakeBin, "node"); + try { + mkdirSync(fakeBin, { recursive: true }); + mkdirSync(fixtureDir, { recursive: true }); + writeFileSync(nodeShim, "#!/usr/bin/env bash\necho node should not run >&2\nexit 1\n"); + chmodSync(nodeShim, 0o755); + + const result = runSweepShell( + ` +set -euo pipefail +export PATH="$FAKE_BIN:$PATH" +export KITCHEN_SINK_SWEEP_SOURCE_ONLY=1 +export KITCHEN_SINK_TMP_DIR="$SCRATCH_ROOT" +export OPENCLAW_CLAWHUB_FIXTURE_WAIT_ATTEMPTS=2x +source scripts/e2e/lib/kitchen-sink-plugin/sweep.sh +set +e +start_kitchen_sink_clawhub_fixture_server "$FIXTURE_DIR" +status="$?" +set -e +cleanup_kitchen_sink_sweep +exit "$status" +`, + { + FAKE_BIN: fakeBin, + FIXTURE_DIR: fixtureDir, + SCRATCH_ROOT: scratchRoot, + }, + ); + + expect(result.status).toBe(2); + expect(result.stderr).toContain("invalid OPENCLAW_CLAWHUB_FIXTURE_WAIT_ATTEMPTS: 2x"); + expect(result.stderr).not.toContain("node should not run"); + } finally { + rmSync(parent, { force: true, recursive: true }); + } + }); + it("bounds ClawHub fixture server logs on startup timeout", () => { const parent = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-sink-clawhub-log-")); const fakeBin = path.join(parent, "bin");