Files
hermes-agent/tests/scripts/install/test_install_ps1_skipsetup_alias.py
Yuan Li e40637dcba test(install): drive -SkipSetup alone through the needs-input stage frame; sync zh-Hans doc
Address review on #125371: the binding test passed the script-level
-NonInteractive alongside the alias, so deleting the fold line kept it
green. The new test runs -Stage setup -Json with only -SkipSetup and
asserts the skipped/needs-user-input frame, which only the fold can
produce (without it the stage dispatches interactively and fails under
a non-interactive host). Also document the deprecated alias in the
zh-Hans windows-native guide, which still said -SkipSetup is rejected.

(cherry picked from commit b97fc4561af918910b8b2b9bf728e501b89aeb27)
2026-09-28 00:58:16 +05:30

65 lines
2.7 KiB
Python

"""Regression for #125350: -SkipSetup must keep binding after the staged-installer rework.
The staged-installer rework (92686159d1) dropped the ``-SkipSetup`` switch from
install.ps1's ``param()`` block, so wrappers written against the old spelling
(hermes-desktop passes ``-SkipSetup -NonInteractive -HermesHome ...``) die at
parameter binding with ``NamedParameterNotFound`` before any stage runs. The
switch is back as a deprecated alias that folds into ``-NonInteractive``.
``-ShowResolvedPaths`` is the installer's side-effect-free contract: it still
exercises real parameter binding and the whole prologue, then prints the
resolved-path report and exits 0.
"""
from __future__ import annotations
import json
import shutil
import subprocess
from pathlib import Path
import pytest
pytestmark = pytest.mark.platforms("windows")
REPO_ROOT = Path(__file__).resolve().parents[3]
INSTALLER = REPO_ROOT / "scripts" / "install.ps1"
def test_skipsetup_still_binds(tmp_path):
powershell = shutil.which("powershell")
assert powershell
result = subprocess.run(
[powershell, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass",
"-File", str(INSTALLER), "-SkipSetup", "-NonInteractive", "-ShowResolvedPaths",
"-HermesHome", str(tmp_path / "home"), "-InstallDir", str(tmp_path / "install")],
capture_output=True, text=True, timeout=120,
)
assert result.returncode == 0, (
"-SkipSetup failed to bind:\n" + result.stderr + result.stdout)
report = json.loads(result.stdout)
assert report, "expected the resolved-paths JSON report on stdout"
def test_skipsetup_alone_skips_needs_input_stage(tmp_path):
"""-SkipSetup without -NonInteractive must fold into it (#125371 review).
Driving ``-Stage setup`` (``needs_user_input = $true``) with only the alias
proves the fold itself: deleting the ``if ($SkipSetup)`` line makes the
stage dispatch run interactively instead of emitting the skipped frame.
"""
powershell = shutil.which("powershell")
assert powershell
result = subprocess.run(
[powershell, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass",
"-File", str(INSTALLER), "-SkipSetup", "-Stage", "setup", "-Json",
"-HermesHome", str(tmp_path / "home"), "-InstallDir", str(tmp_path / "install")],
capture_output=True, text=True, timeout=120,
)
assert result.returncode == 0, (
"-SkipSetup -Stage setup failed:\n" + result.stderr + result.stdout)
frame = json.loads(result.stdout.strip().splitlines()[-1])
assert frame["ok"] is True
assert frame["stage"] == "setup"
assert frame["skipped"] is True, frame
assert frame.get("reason") == "needs user input", frame