Skip to content

The agent that grows with you

test(merge-fix): drop windows-tests' dep_ensure/npm_engine divergent tests; make Exec assertion quote-aware

ethernet4486fe1e30c9
diff --git a/tests/hermes_cli/test_dep_ensure.py b/tests/hermes_cli/test_dep_ensure.py
index cd32d408881..bbf5df939ed 100644
--- a/tests/hermes_cli/test_dep_ensure.py
+++ b/tests/hermes_cli/test_dep_ensure.py
@@ -11,22 +11,6 @@ def test_unknown_dep_refused():
assert ensure_dependency("not-a-dep") is False
-def test_find_install_script_from_checkout(tmp_path):
- """_find_install_script finds scripts/install.sh in a git checkout.
-
- ``platforms("linux")``: the POSIX arm picks ``install.sh`` + ``bash``, which is
- already what ``_IS_WINDOWS`` reports here — nothing needs faking.
- """
- from hermes_cli.dep_ensure import _find_install_script
- scripts_dir = tmp_path / "scripts"
- scripts_dir.mkdir()
- (scripts_dir / "install.sh").write_text("#!/bin/bash", encoding="utf-8")
- path, shell = _find_install_script(package_dir=tmp_path / "hermes_cli", repo_root=tmp_path)
- assert path is not None
- assert path.name == "install.sh"
- assert shell == "bash"
-
def test_available_dep_short_circuits(monkeypatch):
from hermes_cli import dep_ensure
@@ -81,29 +65,3 @@ def test_browser_check_consults_pm(monkeypatch):
assert dep_ensure._browser_available() is True
with patch("pm.is_installed", return_value=False):
assert dep_ensure._browser_available() is False
-
-def test_ensure_dependency_uses_powershell_on_windows(tmp_path):
- """``platforms("windows")``: the assertion is that we shell out to a real
- PowerShell. Faking ``_IS_WINDOWS`` on Linux also required faking
- ``shutil.which`` into inventing a powershell.exe that isn't there."""
- from hermes_cli.dep_ensure import ensure_dependency
- scripts_dir = tmp_path / "scripts"
- scripts_dir.mkdir(parents=True)
- (scripts_dir / "install.ps1").write_text("# fake")
- with patch("hermes_cli.dep_ensure._DEP_CHECKS", {"node": lambda: False}), \
- patch("hermes_cli.dep_ensure._find_install_script", return_value=(scripts_dir / "install.ps1", "powershell")), \
- patch("hermes_cli.dep_ensure.shutil") as mock_shutil, \
- patch("hermes_constants.get_hermes_home", return_value=tmp_path / "fakehome"), \
- patch("subprocess.run") as mock_run, \
- patch("sys.stdin") as mock_stdin:
- mock_shutil.which.side_effect = lambda name: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" if name == "powershell" else None
- mock_stdin.isatty.return_value = False
- mock_run.return_value = type("R", (), {"returncode": 0})()
- ensure_dependency("node", interactive=False)
- cmd = mock_run.call_args[0][0]
- assert "powershell" in cmd[0].lower()
- assert "-Ensure" in cmd
- assert cmd[cmd.index("-Ensure") + 1] == "node"
- assert "-HermesHome" in cmd
- assert str(tmp_path / "fakehome") in cmd
diff --git a/tests/hermes_cli/test_linux_desktop_entry.py b/tests/hermes_cli/test_linux_desktop_entry.py
index aa7a3597936..4485f3ab840 100644
--- a/tests/hermes_cli/test_linux_desktop_entry.py
+++ b/tests/hermes_cli/test_linux_desktop_entry.py
@@ -56,8 +56,17 @@ def test_install_writes_entry_with_absolute_exec_and_icon(
# Exec must be the absolute path of the resolved binary. The launcher
# runs with a minimal PATH, so a bare `hermes` would not resolve.
- assert values["Exec"] == f"{hermes_bin} desktop"
- assert Path(values["Exec"].split(" ")[0]).is_absolute()
+ # _quote_exec_arg quotes it per the desktop-entry spec when the path
+ # contains reserved characters (Windows drive/backslash paths do).
+ exec_value = values["Exec"]
+ exec_parts = exec_value.split(" ")
+ if exec_parts[0].startswith('"'):
+ # quoted path — strip the wrapping quotes for the comparison
+ unquoted = exec_parts[0][1:-1].replace("\\\\", "\\")
+ else:
+ unquoted = exec_parts[0]
+ assert unquoted == str(hermes_bin)
+ assert exec_value.endswith(" desktop")
# Icon must be an absolute path to the real icon in the checkout.
icon_path = Path(values["Icon"])