Skip to content

The agent that grows with you

test(install): products and desktop stages share one completion call

ethernet339a6ac7b6e4
diff --git a/tests/scripts/test_install_sh_launch_handoff.py b/tests/scripts/test_install_sh_launch_handoff.py
index e814055e24f..fe390e170db 100644
--- a/tests/scripts/test_install_sh_launch_handoff.py
+++ b/tests/scripts/test_install_sh_launch_handoff.py
@@ -3,6 +3,7 @@ import json
import os
from pathlib import Path
import subprocess
+import sys
import pytest
from tests.installation_launcher_fixture import publish_fixture_launcher
@@ -10,7 +11,7 @@ from tests.installation_launcher_fixture import publish_fixture_launcher
ROOT = Path(__file__).resolve().parents[2]
@pytest.mark.platforms('posix')
[email protected]('stage, expected', [('setup', ['setup']), ('gateway', ['gateway', 'install']), ('desktop', ['desktop', '--build-only'])])
[email protected]('stage, expected', [('setup', ['setup']), ('gateway', ['gateway', 'install'])])
def test_installer_post_pm_stages(tmp_path: Path, stage: str, expected: list[str]) -> None:
install = tmp_path / 'source tree'
calls = tmp_path / 'calls.json'
@@ -24,8 +25,37 @@ def test_installer_post_pm_stages(tmp_path: Path, stage: str, expected: list[str
assert not (install / 'venv').exists()
[email protected]('stage, include_desktop, expected_desktop', [
+ ('products', False, False), ('products', True, True), ('desktop', False, True),
+])
+def test_products_and_desktop_stages_share_the_completion_tail(tmp_path: Path, stage: str,
+ include_desktop: bool, expected_desktop: bool) -> None:
+ """Both stages hand the checkout to hermes_cli/source_completion.py; --include-desktop
+ (or the external `desktop` stage) only adds --desktop to that one call."""
+ install = tmp_path / 'source tree'
+ calls = tmp_path / 'calls.json'
+ (install / 'hermes_cli').mkdir(parents=True)
+ (install / 'hermes_cli' / 'source_completion.py').write_text(
+ "import json, os, sys\nfrom pathlib import Path\n"
+ "Path(os.environ['CALLS']).write_text(json.dumps(sys.argv[1:]))\n", encoding='utf-8')
+ flag = 'true' if include_desktop else 'false'
+ command = ['bash', '-c',
+ f'source "$1" --manifest >/dev/null; INSTALL_DIR="$2"; INCLUDE_DESKTOP={flag}; '
+ 'bootstrap_python() { boot_py="$PYTHON_FOR_TEST"; }; "stage_$3"',
+ 'test', str(ROOT / 'scripts/install.sh'), str(install), stage]
+ env = {**os.environ, 'HOME': str(tmp_path), 'HERMES_HOME': str(tmp_path / 'home'),
+ 'HERMES_RUNTIME_DIR': str(tmp_path / 'store'), 'CALLS': str(calls), 'PYTHON_FOR_TEST': sys.executable}
+ result = subprocess.run(command, cwd=tmp_path, env=env, capture_output=True, text=True, timeout=20)
+ assert result.returncode == 0, result.stdout + result.stderr
+ argv = json.loads(calls.read_text())
+ assert argv[:2] == ['--source', str(install)]
+ assert ('--desktop' in argv) is expected_desktop
+
+
@pytest.mark.platforms("posix")
-def test_desktop_flag_only_inserts_desktop_before_completion(tmp_path):
+def test_desktop_flag_does_not_add_a_stage(tmp_path):
+ """--include-desktop selects the desktop product inside `products`; the manifest is one ladder."""
def manifest(*flags):
result = subprocess.run(
["bash", str(ROOT / "scripts/install.sh"), "--manifest", *flags],
@@ -34,7 +64,7 @@ def test_desktop_flag_only_inserts_desktop_before_completion(tmp_path):
return [row["name"] for row in json.loads(result.stdout)["stages"]]
plain = manifest()
- desktop = manifest("--include-desktop")
assert "desktop" not in plain
+ assert "products" in plain
assert plain[-1] == "complete"
- assert desktop == [*plain[:-1], "desktop", "complete"]
\ No newline at end of file
+ assert manifest("--include-desktop") == plain