The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(install): run the treeless re-run case through install.ps1 too
Tekniumadeecd8638a1
diff --git a/tests/scripts/install/test_install_clone_throttle_fallback.py b/tests/scripts/install/test_install_clone_throttle_fallback.pyindex 25c8edcad0a..3543993a018 100644--- a/tests/scripts/install/test_install_clone_throttle_fallback.py+++ b/tests/scripts/install/test_install_clone_throttle_fallback.py@@ -1,7 +1,9 @@"""A throttled clone is retried without publishing a partial checkout."""+import jsonimport osfrom pathlib import Pathimport shlex+import shutilimport subprocessimport pytest@@ -14,11 +16,11 @@ def test_clone_retries_and_publishes_only_materialized_tree(tmp_path, materializorigin = tmp_path / "origin"origin.mkdir()def git(*args):- return subprocess.run(["git", "-C", str(origin), *args], check=True, capture_output=True, text=True)+ return subprocess.run(["git", "-C", str(origin), *args], check=True, capture_output=True, text=True, encoding="utf-8", errors="replace")git("init", "-b", "main")git("config", "user.email", "[email protected]")git("config", "user.name", "Fixture")- (origin / "README").write_text("complete checkout\n")+ (origin / "README").write_text("complete checkout\n", encoding="utf-8")git("add", "README")git("commit", "-m", "fixture")dest = tmp_path / "install"@@ -38,8 +40,8 @@ git() {{}}stage_repository'''- result = subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True, timeout=30)- calls = attempts.read_text().splitlines()+ result = subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30)+ calls = attempts.read_text(encoding="utf-8-sig").splitlines()assert len(calls) > 1assert "--no-checkout" in calls[-1]if materialize_fails:@@ -47,26 +49,54 @@ stage_repositoryassert not dest.exists()else:assert result.returncode == 0, result.stdout + result.stderr- assert (dest / "README").read_text() == "complete checkout\n"+ assert (dest / "README").read_text(encoding="utf-8-sig") == "complete checkout\n"assert not list(tmp_path.glob(".hermes-clone-*"))-def test_existing_treeless_checkout_is_refetched_before_update(tmp_path):+POWERSHELL = next((c for c in ("pwsh", "powershell") if shutil.which(c)), None)+++def _run_repository_stage(installer: str, tmp_path: Path, install: Path, origin_url: str) -> subprocess.CompletedProcess:+ env = dict(os.environ, HOME=tmp_path.as_posix(), HERMES_HOME=(tmp_path / "home").as_posix(),+ HERMES_INSTALL_DIR=install.as_posix(), HERMES_REPO_URL=origin_url)+ if installer == "sh":+ script = f"source {shlex.quote((ROOT / 'scripts/install.sh').as_posix())} --manifest\nstage_repository\n"+ return subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=60)+ if os.name != "nt":+ # pwsh on POSIX cannot run the Windows-only pinned Git: seed its PM store slot with host git.+ version = json.loads((ROOT / "pm" / "lock.json").read_text(encoding="utf-8-sig"))["packages"]["git"]["version"]+ cmd = tmp_path / "tools" / f"git-{version}-win32-x64" / "cmd"+ cmd.mkdir(parents=True)+ for name in ("git.exe", "git"):+ (cmd / name).symlink_to(shutil.which("git"))+ env.update(HERMES_RUNTIME_DIR=str(tmp_path / "tools"), PATH=str(cmd) + os.pathsep + env["PATH"])+ return subprocess.run([POWERSHELL, "-NoProfile", "-File", str(ROOT / "scripts" / "install.ps1"),+ "-Stage", "repository", "-NonInteractive", "-InstallDir", str(install),+ "-HermesHome", str(tmp_path / "home")],+ env=env, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=240)++[email protected]_system_guard_bypass[email protected]("installer", [+ "sh",+ pytest.param("ps1", marks=pytest.mark.skipif(POWERSHELL is None, reason="needs PowerShell")),+])+def test_existing_treeless_checkout_is_refetched_before_update(tmp_path, installer):origin = tmp_path / "origin.git"source = tmp_path / "source"install = tmp_path / "install"subprocess.run(["git", "init", "--bare", "-b", "main", str(origin)], check=True, capture_output=True)- def git(cwd, *args):+ def git(cwd, *args, **env):return subprocess.run(["git", "-C", str(cwd), *args], check=True,- capture_output=True, text=True)+ capture_output=True, text=True, encoding="utf-8", errors="replace", env={**os.environ, **env})source.mkdir()git(source, "init", "-b", "main")git(source, "config", "user.email", "[email protected]")git(source, "config", "user.name", "Fixture")for index in range(5):- (source / "history.txt").write_text(f"commit {index}\n")+ (source / "history.txt").write_text(f"commit {index}\n", encoding="utf-8")git(source, "add", "history.txt")git(source, "commit", "-m", f"history {index}")git(source, "remote", "add", "origin", origin.as_posix())@@ -76,17 +106,12 @@ def test_existing_treeless_checkout_is_refetched_before_update(tmp_path):# A file:// URL: git ignores --filter on a plain-path clone and would copy every tree.subprocess.run(["git", "clone", "--filter=tree:0", origin.as_uri(), install.as_posix()],- check=True, capture_output=True, text=True)+ check=True, capture_output=True, text=True, encoding="utf-8", errors="replace")assert git(install, "config", "--get", "remote.origin.partialclonefilter").stdout.strip() == "tree:0"head = git(install, "rev-parse", "HEAD").stdout.strip()- env = dict(os.environ, HOME=tmp_path.as_posix(), HERMES_HOME=(tmp_path / "home").as_posix(),- HERMES_INSTALL_DIR=install.as_posix(), HERMES_REPO_URL=origin.as_uri())- script = f'''source {shlex.quote((ROOT / 'scripts/install.sh').as_posix())} --manifest-stage_repository-GIT_NO_LAZY_FETCH=1 git -C {shlex.quote(install.as_posix())} rev-list HEAD -- history.txt-'''- result = subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True, timeout=30)+ result = _run_repository_stage(installer, tmp_path, install, origin.as_uri())assert result.returncode == 0, result.stdout + result.stderrassert git(install, "config", "--get", "remote.origin.partialclonefilter").stdout.strip() == "blob:none"assert git(install, "rev-parse", "HEAD").stdout.strip() == head, "the checkout was re-cloned, not converted"+ git(install, "rev-list", "HEAD", "--", "history.txt", GIT_NO_LAZY_FETCH="1") # history answers offline