Skip to content

The agent that grows with you

test(install): installer contracts follow the rerun and invocation fixes

ethernet7c41603da9d5
diff --git a/tests/fixtures/resolution_allowlist.json b/tests/fixtures/resolution_allowlist.json
index 72ccfced9c9..3dd21948554 100644
--- a/tests/fixtures/resolution_allowlist.json
+++ b/tests/fixtures/resolution_allowlist.json
@@ -439,6 +439,11 @@
"symbol": "find_node_executable",
"kind": "bare_which"
},
+ {
+ "path": "pm/native_build.py",
+ "symbol": "prepare_windows_environment",
+ "kind": "bare_which"
+ },
{
"path": "pm/shell.py",
"symbol": "bash",
diff --git a/tests/scripts/install/test_install_ps1_managed_python_provenance.py b/tests/scripts/install/test_install_ps1_managed_python_provenance.py
index 74792ea0070..37b815226fc 100644
--- a/tests/scripts/install/test_install_ps1_managed_python_provenance.py
+++ b/tests/scripts/install/test_install_ps1_managed_python_provenance.py
@@ -65,7 +65,7 @@ exit $LASTEXITCODE
capture_output=True, text=True, timeout=120)
assert (run.returncode == 0) == (exit_code == 0), run.stdout + run.stderr
assert [json.loads(line) for line in log.read_text(encoding="utf-8-sig").splitlines()] == [
- ["python", "install", "--no-bin", "3.12"], ["python", "find", "--managed-python", "--no-project", "3.12"],
+ ["python", "install", "--no-bin", "--no-registry", "3.12"], ["python", "find", "--managed-python", "--no-project", "3.12"],
]
if stage == "python-deps":
assert json.loads(pm_log.read_text(encoding="utf-8-sig")) == ["install"]
diff --git a/tests/scripts/install/test_install_sh_repository_stage.py b/tests/scripts/install/test_install_sh_repository_stage.py
index 9fee1063e67..c5fe4256efd 100644
--- a/tests/scripts/install/test_install_sh_repository_stage.py
+++ b/tests/scripts/install/test_install_sh_repository_stage.py
@@ -118,7 +118,8 @@ def test_unmerged_index_is_cleared_then_stashed(tmp_path):
_commit(install, "theirs")
_git(install, "checkout", "-q", "main")
_commit(install, "ours")
- subprocess.run(["git", "-C", str(install), "merge", "conflict"], capture_output=True)
+ subprocess.run(["git", "-C", str(install), "-c", "user.email=t@t", "-c", "user.name=t", "merge", "conflict"],
+ capture_output=True)
assert _git(install, "ls-files", "--unmerged")
_commit(origin, "two")
result = _stage(tmp_path, origin)
diff --git a/tests/scripts/test_install_sh_launch_handoff.py b/tests/scripts/test_install_sh_launch_handoff.py
index fe390e170db..a0ecf4845ac 100644
--- a/tests/scripts/test_install_sh_launch_handoff.py
+++ b/tests/scripts/test_install_sh_launch_handoff.py
@@ -8,8 +8,21 @@ import sys
import pytest
from tests.installation_launcher_fixture import publish_fixture_launcher
+if os.name == 'posix':
+ import fcntl
+ import pty
+ import termios
+
ROOT = Path(__file__).resolve().parents[2]
+def _with_controlling_terminal(slave: int):
+ """preexec_fn: make ``slave`` this child's controlling terminal, so /dev/tty opens."""
+ def attach() -> None:
+ os.setsid() # windows-footgun: ok (posix-only test)
+ fcntl.ioctl(slave, termios.TIOCSCTTY, 0)
+ return attach
+
+
@pytest.mark.platforms('posix')
@pytest.mark.parametrize('stage, expected', [('setup', ['setup']), ('gateway', ['gateway', 'install'])])
def test_installer_post_pm_stages(tmp_path: Path, stage: str, expected: list[str]) -> None:
@@ -18,10 +31,22 @@ def test_installer_post_pm_stages(tmp_path: Path, stage: str, expected: list[str
publish_fixture_launcher(install, "import json, os, sys\nfrom pathlib import Path\ndef main():\n Path(os.environ['CALLS']).write_text(json.dumps(sys.argv[1:])); return int(os.environ['STAGE_EXIT'])\n")
command = ['bash', '-c', 'source "$1" --manifest >/dev/null; INSTALL_DIR="$2"; NON_INTERACTIVE=false; "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)}
- for code in [0, 9]:
- result = subprocess.run(command, cwd=tmp_path, env={**env, 'STAGE_EXIT': str(code)}, capture_output=True, text=True, timeout=20)
- assert (result.returncode == 0) == (code == 0), result.stdout + result.stderr
- assert json.loads(calls.read_text()) == expected
+ # `curl | bash` and Docker builds have no terminal: the interactive stage is skipped, not failed.
+ result = subprocess.run(command, cwd=tmp_path, env={**env, 'STAGE_EXIT': '9'}, capture_output=True, text=True,
+ encoding='utf-8', timeout=20, start_new_session=True)
+ assert result.returncode == 0, result.stdout + result.stderr
+ assert not calls.exists()
+ master, slave = pty.openpty()
+ try:
+ for code in [0, 9]:
+ result = subprocess.run(command, cwd=tmp_path, env={**env, 'STAGE_EXIT': str(code)}, capture_output=True,
+ text=True, encoding='utf-8', timeout=20, stdin=subprocess.DEVNULL, preexec_fn=_with_controlling_terminal(slave),
+ pass_fds=(slave,))
+ assert (result.returncode == 0) == (code == 0), result.stdout + result.stderr
+ assert json.loads(calls.read_text()) == expected
+ finally:
+ os.close(master)
+ os.close(slave)
assert not (install / 'venv').exists()
diff --git a/tests/scripts/test_install_stage_frames.py b/tests/scripts/test_install_stage_frames.py
index 4426844f505..19e8ea76dd9 100644
--- a/tests/scripts/test_install_stage_frames.py
+++ b/tests/scripts/test_install_stage_frames.py
@@ -33,6 +33,9 @@ def test_stage_result_matches_the_actual_exit(tmp_path, case):
repo = tmp_path / "install"
repo.mkdir()
subprocess.run(["git", "init", "-q", "-b", "main", str(repo)], check=True, capture_output=True)
+ # A commit makes it a real checkout; an empty one is an interrupted clone that gets re-cloned.
+ subprocess.run(["git", "-C", str(repo), "-c", "user.name=t", "-c", "user.email=t@t", "commit", "-q",
+ "--allow-empty", "-m", "fixture"], check=True, capture_output=True)
subprocess.run(["git", "-C", str(repo), "remote", "add", "origin", str(tmp_path / "missing")],
check=True, capture_output=True)
elif case == "write-failure":