Skip to content

The agent that grows with you

fix: route macOS DMG CLI E2E through staged branch probe

ethernet46a08dddd4a4
diff --git a/tests/install/macos-desktop-e2e.sh b/tests/install/macos-desktop-e2e.sh
index dda21c5f9fc..f3970ccaa92 100755
--- a/tests/install/macos-desktop-e2e.sh
+++ b/tests/install/macos-desktop-e2e.sh
@@ -96,6 +96,8 @@ source "$(dirname "$0")/e2e-assets/ts-prefix.sh" 2>/dev/null || ts_prefix() { ca
source "$(dirname "$0")/e2e-assets/preserve-plugins.sh"
# shellcheck source=e2e-assets/source-driver.sh
source "$(dirname "$0")/e2e-assets/source-driver.sh"
+# shellcheck source=e2e-assets/source-update-command.sh
+source "$ASSETS/source-update-command.sh"
# shellcheck source=e2e-assets/installer-common.sh
source "$(dirname "$0")/e2e-assets/installer-common.sh"
# shellcheck source=e2e-assets/source-build-env.sh
@@ -301,15 +303,16 @@ phase_update() {
trap mock_stop EXIT
case "$UPDATE_METHOD" in
hermes-update)
- # The CLI route a dmg user takes from a terminal. `--yes` reaches the
- # update subcommand only in later releases; ask the installed hermes.
+ # The CLI route a dmg user takes from a terminal. Probe the installed
+ # help for both flags: this fixture stages unpublished main in serve.git,
+ # so newer updaters need explicit --branch main (not the channel object).
local hermes help
hermes="$(source_hermes "$INSTALL_DIR")" || fail "no installed update command"
- local update_cmd=("$hermes" update)
help="$(source_build_env "$hermes" update --help 2>&1)" || fail "installed update --help failed: $help"
- if grep -qF -- --yes <<< "$help"; then
- update_cmd=("$hermes" update --yes)
- fi
+ build_source_update_command "$hermes" "$help"
+ printf ' CLI update invocation:'
+ printf ' %q' "${update_cmd[@]}"
+ printf '\n'
local rc=0
(cd "$INSTALL_DIR" && source_build_env "${update_cmd[@]}" < /dev/null 2>&1 | ts_prefix > "$LOG_DIR/update.log") || rc=$?
log_group "hermes update transcript" "$LOG_DIR/update.log"
diff --git a/tests/scripts/test_source_update_command.py b/tests/scripts/test_source_update_command.py
index c7fe279cd89..0c90728d321 100644
--- a/tests/scripts/test_source_update_command.py
+++ b/tests/scripts/test_source_update_command.py
@@ -3,11 +3,14 @@
import os
from pathlib import Path
import subprocess
+import sys
import pytest
HELPER = Path(__file__).resolve().parents[1] / "install/e2e-assets/source-update-command.sh"
+SOURCE_BUILD_ENV = HELPER.with_name("source-build-env.sh")
+REPO_ROOT = HELPER.parents[3]
@pytest.mark.platforms("posix")
@@ -42,3 +45,36 @@ fi
assert result.returncode == 0, result.stderr
assert result.stdout.strip().endswith(expected)
assert "Channel object not found" not in result.stderr
+
+
[email protected]_system_guard_bypass # --help exits in argparse, before the update handler.
+def test_installed_cli_help_drives_explicit_staged_branch(tmp_path):
+ # Use the real update parser's help, not a synthetic one-line help fixture.
+ # The fake executable only replaces the destructive update action.
+ env = dict(os.environ, HERMES_DISABLE_LAZY_INSTALLS="1", PYTHONDONTWRITEBYTECODE="1")
+ help_result = subprocess.run(
+ [sys.executable, "-m", "hermes_cli.main", "update", "--help"],
+ cwd=REPO_ROOT, env=env, capture_output=True, text=True, timeout=60,
+ )
+ assert help_result.returncode == 0, help_result.stderr
+ cli = tmp_path / "installed hermes"
+ cli.write_text('''#!/usr/bin/env bash
+[[ "$1" == update ]] || exit 2
+shift
+[[ " $* " == *" --yes "* && " $* " == *" --branch main "* ]] || {
+ printf 'Channel object not found: releases/channels/main.json\\n' >&2
+ exit 1
+}
+printf 'selected staged main: %s\\n' "$*"
+''', encoding="utf-8")
+ cli.chmod(0o755)
+ result = subprocess.run(
+ ["bash", "-euc", 'source "$HELPER"; source "$SOURCE_BUILD_ENV"; '
+ 'build_source_update_command "$CLI" "$HELP_TEXT"; source_build_env "${update_cmd[@]}"'],
+ env=dict(env, HELPER=str(HELPER), SOURCE_BUILD_ENV=str(SOURCE_BUILD_ENV),
+ CLI=str(cli), HELP_TEXT=help_result.stdout),
+ cwd=REPO_ROOT, capture_output=True, text=True, timeout=30,
+ )
+ assert result.returncode == 0, result.stderr
+ assert "selected staged main: --yes --branch main" in result.stdout