hermes-agent/tests/hermes_cli/test_uninstall_windows_bin_launchers.py
ethernet 3d12e86ef1 feat(pm): unified package manager — pm store foundation
Introduce the pm store: a unified, hash-verified package store that
replaces lazy_deps and the old installer's ad-hoc tool downloads.
Store tools are provisioned on PATH (ffmpeg, node/npm via pinned uv),
with a resumable 8-way downloader, verify() returning failure reasons,
and adopt() made EPERM-safe. chromium ships in the payload for every
target. The 3600-line install.sh is replaced by a staged bootstrapper
(heavy deps are pm's job after this); setup-hermes.sh, Dockerfile and
nix pin tables are rewired onto the store. Old install-script tests,
lazy_deps/managed_uv/build_info, and the ps1/bash installer test
batteries are removed with the machinery they tested.

Rebuilt from ethie/pm onto upstream/main (ac6c8028e0) after the
utf-8-sig sweep. 16 hot files (main also churned them) hand-merged:
platform adapters, main.py, electron/main.ts, tui_gateway/server.py,
cua_backend, installer-tests workflow, install.sh (full rewrite),
setup-hermes.sh, plugins doc.
2026-08-31 18:00:48 -04:00

64 lines
2.3 KiB
Python

"""Uninstall must not leave a dangling ``hermes`` command on Windows.
Every uninstall mode deletes the code checkout, but the launcher copies
staged onto PATH in the managed binary dir (the default Hermes root's
``bin``) live outside it. A surviving launcher makes ``hermes`` in a new
terminal resolve and then error on its missing venv target — worse than
command-not-found. The dir is wholly hermes-owned (pm keeps uv in its own
store entry), so the sweep takes everything in it.
Platform verdicts are injected parameters (input→output, not host fakes).
"""
from __future__ import annotations
from pathlib import Path
import pytest
from hermes_cli import uninstall
@pytest.fixture
def managed_bin(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
"""Default-root ``bin`` holding staged launcher copies."""
home = tmp_path / "hermes"
bin_dir = home / "bin"
bin_dir.mkdir(parents=True)
(bin_dir / "hermes.exe").write_bytes(b"MZ launcher")
(bin_dir / "hermes-acp.cmd").write_text("@echo off\r\n", encoding="ascii")
monkeypatch.setenv("HERMES_HOME", str(home))
return bin_dir
def test_removes_the_whole_managed_bin_dir(managed_bin: Path):
removed = uninstall.remove_windows_bin_launchers(windows=True)
assert sorted(p.name for p in removed) == ["hermes-acp.cmd", "hermes.exe"]
assert not managed_bin.exists()
def test_anchors_on_default_root_not_profile_home(
managed_bin: Path, monkeypatch: pytest.MonkeyPatch
):
"""The launcher dir is per-machine; a profile HERMES_HOME must not
redirect the sweep into ``profiles/<name>/bin``."""
home = managed_bin.parent
monkeypatch.setenv("HERMES_HOME", str(home / "profiles" / "work"))
removed = uninstall.remove_windows_bin_launchers(windows=True)
assert sorted(p.name for p in removed) == ["hermes-acp.cmd", "hermes.exe"]
assert not (managed_bin / "hermes.exe").exists()
def test_noop_on_posix(managed_bin: Path):
assert uninstall.remove_windows_bin_launchers(windows=False) == []
assert (managed_bin / "hermes.exe").exists()
def test_noop_when_no_bin_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
home = tmp_path / "hermes"
home.mkdir()
monkeypatch.setenv("HERMES_HOME", str(home))
assert uninstall.remove_windows_bin_launchers(windows=True) == []