diff --git a/scripts/e2e/lib/doctor-install-switch/scenario.sh b/scripts/e2e/lib/doctor-install-switch/scenario.sh index 4090607ee411..a58e94398a02 100644 --- a/scripts/e2e/lib/doctor-install-switch/scenario.sh +++ b/scripts/e2e/lib/doctor-install-switch/scenario.sh @@ -74,6 +74,8 @@ create_default_service_state() { "$account_home/.local/bin/openclaw-wrapper" \ "$account_home/openclaw-wrapper-argv.log" openclaw_test_state_create "$account_home" empty + export HOME="$account_home" + export USERPROFILE="$account_home" unset OPENCLAW_HOME OPENCLAW_STATE_DIR OPENCLAW_CONFIG_PATH } diff --git a/scripts/e2e/lib/upgrade-survivor/run.sh b/scripts/e2e/lib/upgrade-survivor/run.sh index 102f3aefdb8f..dc39700dc377 100644 --- a/scripts/e2e/lib/upgrade-survivor/run.sh +++ b/scripts/e2e/lib/upgrade-survivor/run.sh @@ -690,6 +690,7 @@ install_baseline() { } seed_state() { + local account_home="" openclaw_e2e_eval_test_state_from_b64 "${OPENCLAW_TEST_STATE_FUNCTION_B64:?missing OPENCLAW_TEST_STATE_FUNCTION_B64}" if [ "$ROOT_MANAGED_VPS" = "1" ]; then if [ "$(id -u)" -ne 0 ]; then @@ -701,6 +702,17 @@ seed_state() { else openclaw_test_state_create "$STATE_HOME_ROOT" minimal fi + if [ "$UPDATE_RESTART_MODE" = "auto-auth" ]; then + account_home="$(getent passwd "$(id -u)" | cut -d: -f6)" + if [ -z "$account_home" ]; then + echo "Could not resolve the current account home" >&2 + return 1 + fi + export HOME="$account_home" + export USERPROFILE="$account_home" + export OPENCLAW_STATE_DIR="$account_home/.openclaw" + export OPENCLAW_CONFIG_PATH="$OPENCLAW_STATE_DIR/openclaw.json" + fi export OPENCLAW_UPGRADE_SURVIVOR_BASELINE_VERSION="$baseline_version" node scripts/e2e/lib/upgrade-survivor/assertions.mjs seed } diff --git a/test/scripts/docker-build-helper.test.ts b/test/scripts/docker-build-helper.test.ts index 617324bdf0b9..ff753665cbb9 100644 --- a/test/scripts/docker-build-helper.test.ts +++ b/test/scripts/docker-build-helper.test.ts @@ -4390,7 +4390,12 @@ heartbeat_elapsed="\${BASH_REMATCH[1]}" expectTextToIncludeAll(scenario, [ 'command_timeout="${OPENCLAW_DOCKER_DOCTOR_SWITCH_COMMAND_TIMEOUT:-900s}"', - 'openclaw_test_state_create "$account_home" empty\n unset OPENCLAW_HOME OPENCLAW_STATE_DIR OPENCLAW_CONFIG_PATH', + [ + 'openclaw_test_state_create "$account_home" empty', + ' export HOME="$account_home"', + ' export USERPROFILE="$account_home"', + " unset OPENCLAW_HOME OPENCLAW_STATE_DIR OPENCLAW_CONFIG_PATH", + ].join("\n"), "create_default_service_state", 'openclaw_e2e_maybe_timeout "$command_timeout" bash -c "$install_cmd"', 'openclaw_e2e_maybe_timeout "$command_timeout" bash -c "$doctor_cmd"', @@ -4401,9 +4406,28 @@ heartbeat_elapsed="\${BASH_REMATCH[1]}" expect( scenario.match(/unset OPENCLAW_HOME OPENCLAW_STATE_DIR OPENCLAW_CONFIG_PATH/gu), ).toHaveLength(1); + expect(scenario.match(/export USERPROFILE="\$account_home"/gu)).toHaveLength(1); expect(scenario).not.toMatch(/^\s*if ! timeout "\$command_timeout"/mu); }); + it("uses the account home for upgrade survivor auto-auth state", () => { + const runner = readFileSync(UPGRADE_SURVIVOR_RUN_SCRIPT, "utf8"); + + expectTextToIncludeAll(runner, [ + 'if [ "$UPDATE_RESTART_MODE" = "auto-auth" ]; then', + 'account_home="$(getent passwd "$(id -u)" | cut -d: -f6)"', + 'if [ -z "$account_home" ]; then', + 'export HOME="$account_home"', + 'export USERPROFILE="$account_home"', + 'export OPENCLAW_STATE_DIR="$account_home/.openclaw"', + 'export OPENCLAW_CONFIG_PATH="$OPENCLAW_STATE_DIR/openclaw.json"', + ]); + + expect( + runner.indexOf('export OPENCLAW_CONFIG_PATH="$OPENCLAW_STATE_DIR/openclaw.json"'), + ).toBeLessThan(runner.indexOf("node scripts/e2e/lib/upgrade-survivor/assertions.mjs seed")); + }); + it("bounds doctor install switch command log diagnostics", () => { const scenario = readFileSync(DOCTOR_SWITCH_SCENARIO_PATH, "utf8");