Files
hermes-agent/tests/scripts/install/test_install_ps1_script_suites.py
ethernet 13ebc163a1 ci: fold the PowerShell installer job into the tests-os Windows lanes
installer-tests.yml predates nothing it still owned. Its pytest step
(test_source_launcher_stages.py) is platforms("windows") and already runs in
both tests-os Windows lanes, so every installer PR ran it twice. The
`installer` lane never gated anything on its own either: every path that set
it also sets `python`, which gates tests-os.

The two standalone scripts/tests/*.ps1 suites become one platforms("windows")
pytest file parametrized over Windows PowerShell 5.1 and pwsh 7, so
list_os_marked_tests picks them up with everything else. The `installer` lane
goes away from the classifier, detect-changes, ci.yaml and the
all-checks-pass gate; the classifier contract now pins that install.ps1 and
its suites turn `python` on.
2026-09-23 17:19:29 -04:00

33 lines
1.4 KiB
Python

"""install.ps1's self-contained PowerShell suites, under Windows PowerShell 5.1 and pwsh 7.
``scripts/tests/*.ps1`` drive the real installer as a subprocess and exit
non-zero on any failed assertion. install.ps1 is delivered via ``irm | iex``
into whatever shell the user already has, and 5.1 is what ships with Windows,
so each suite runs under both: a construct that only parses under 7 is a broken
installer for most of the people hitting it.
"""
import os
from pathlib import Path
import shutil
import subprocess
import pytest
pytestmark = pytest.mark.platforms("windows")
SUITES = Path(__file__).resolve().parents[3] / "scripts" / "tests"
def _shell(name: str) -> str:
if name == "powershell":
return str(Path(os.environ["SystemRoot"]) / "System32/WindowsPowerShell/v1.0/powershell.exe")
return shutil.which("pwsh") or pytest.fail("native lane requires PowerShell 7")
@pytest.mark.parametrize("shell", ["powershell", "pwsh"])
@pytest.mark.parametrize("suite", sorted(p.name for p in SUITES.glob("test-install-ps1-*.ps1")))
def test_suite_passes(shell, suite):
result = subprocess.run([_shell(shell), "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass",
"-File", str(SUITES / suite)],
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=300)
assert result.returncode == 0, result.stdout + result.stderr