mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-23 05:31:23 +00:00
fix(update): use termux-all uv fallback path on Termux
This commit is contained in:
parent
3863d6d344
commit
6d5d467d39
3 changed files with 86 additions and 32 deletions
|
|
@ -111,12 +111,14 @@ class TestCmdUpdateBranchFallback:
|
|||
def test_update_refreshes_repo_and_tui_node_dependencies(
|
||||
self, mock_run, mock_which, mock_args
|
||||
):
|
||||
from hermes_cli import main as hm
|
||||
|
||||
mock_which.side_effect = {"uv": "/usr/bin/uv", "npm": "/usr/bin/npm"}.get
|
||||
mock_run.side_effect = _make_run_side_effect(
|
||||
branch="main", verify_ok=True, commit_count="1"
|
||||
)
|
||||
|
||||
cmd_update(mock_args)
|
||||
with patch.object(hm, "_is_termux_env", return_value=False):
|
||||
cmd_update(mock_args)
|
||||
|
||||
npm_calls = [
|
||||
(call.args[0], call.kwargs.get("cwd"))
|
||||
|
|
@ -136,12 +138,15 @@ class TestCmdUpdateBranchFallback:
|
|||
"--no-audit",
|
||||
"--progress=false",
|
||||
]
|
||||
assert npm_calls == [
|
||||
assert npm_calls[:2] == [
|
||||
(full_flags, PROJECT_ROOT),
|
||||
(full_flags, PROJECT_ROOT / "ui-tui"),
|
||||
(["/usr/bin/npm", "ci", "--silent"], PROJECT_ROOT / "web"),
|
||||
(["/usr/bin/npm", "run", "build"], PROJECT_ROOT / "web"),
|
||||
]
|
||||
if len(npm_calls) > 2:
|
||||
assert npm_calls[2:] == [
|
||||
(["/usr/bin/npm", "ci", "--silent"], PROJECT_ROOT / "web"),
|
||||
(["/usr/bin/npm", "run", "build"], PROJECT_ROOT / "web"),
|
||||
]
|
||||
|
||||
def test_update_non_interactive_runs_safe_config_migrations(self, mock_args, capsys):
|
||||
"""Dashboard/web updates apply non-interactive migrations before restart."""
|
||||
|
|
@ -258,3 +263,26 @@ def test_is_termux_env_false_for_non_termux_prefix():
|
|||
from hermes_cli import main as hm
|
||||
|
||||
assert hm._is_termux_env({"PREFIX": "/usr/local"}) is False
|
||||
|
||||
|
||||
def test_load_installable_optional_extras_supports_termux_group(tmp_path, monkeypatch):
|
||||
from hermes_cli import main as hm
|
||||
|
||||
pyproject = tmp_path / "pyproject.toml"
|
||||
pyproject.write_text(
|
||||
"""
|
||||
[project]
|
||||
name = "x"
|
||||
version = "0.0.0"
|
||||
|
||||
[project.optional-dependencies]
|
||||
all = ["x[mcp]"]
|
||||
termux-all = ["x[termux]", "x[mcp]"]
|
||||
mcp = ["mcp>=1"]
|
||||
termux = ["rich>=14"]
|
||||
""".strip()
|
||||
)
|
||||
monkeypatch.setattr(hm, "PROJECT_ROOT", tmp_path)
|
||||
|
||||
assert hm._load_installable_optional_extras(group="all") == ["mcp"]
|
||||
assert hm._load_installable_optional_extras(group="termux-all") == ["termux", "mcp"]
|
||||
|
|
|
|||
|
|
@ -311,7 +311,8 @@ def test_cmd_update_retries_optional_extras_individually_when_all_fails(monkeypa
|
|||
"""When .[all] fails, update should keep base deps and retry extras individually."""
|
||||
_setup_update_mocks(monkeypatch, tmp_path)
|
||||
monkeypatch.setattr("shutil.which", lambda name: "/usr/bin/uv" if name == "uv" else None)
|
||||
monkeypatch.setattr(hermes_main, "_load_installable_optional_extras", lambda: ["matrix", "mcp"])
|
||||
monkeypatch.setattr(hermes_main, "_is_termux_env", lambda env=None: False)
|
||||
monkeypatch.setattr(hermes_main, "_load_installable_optional_extras", lambda group="all": ["matrix", "mcp"])
|
||||
|
||||
recorded = []
|
||||
|
||||
|
|
@ -360,6 +361,7 @@ def test_cmd_update_succeeds_with_extras(monkeypatch, tmp_path):
|
|||
"""When .[all] succeeds, no fallback should be attempted."""
|
||||
_setup_update_mocks(monkeypatch, tmp_path)
|
||||
monkeypatch.setattr("shutil.which", lambda name: "/usr/bin/uv" if name == "uv" else None)
|
||||
monkeypatch.setattr(hermes_main, "_is_termux_env", lambda env=None: False)
|
||||
|
||||
recorded = []
|
||||
|
||||
|
|
@ -384,6 +386,36 @@ def test_cmd_update_succeeds_with_extras(monkeypatch, tmp_path):
|
|||
assert ".[all]" in install_cmds[0]
|
||||
|
||||
|
||||
def test_install_with_optional_fallback_honors_custom_group(monkeypatch):
|
||||
"""Termux update path should target .[termux-all] when requested."""
|
||||
calls = []
|
||||
monkeypatch.setattr(
|
||||
hermes_main,
|
||||
"_load_installable_optional_extras",
|
||||
lambda group="all": ["termux", "mcp"] if group == "termux-all" else [],
|
||||
)
|
||||
|
||||
def fake_run_with_heartbeat(cmd, **kwargs):
|
||||
calls.append(cmd)
|
||||
if cmd[-1] == ".[termux-all]":
|
||||
raise CalledProcessError(returncode=1, cmd=cmd)
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(hermes_main, "_run_install_with_heartbeat", fake_run_with_heartbeat)
|
||||
|
||||
hermes_main._install_python_dependencies_with_optional_fallback(
|
||||
["/usr/bin/uv", "pip"],
|
||||
group="termux-all",
|
||||
)
|
||||
|
||||
assert calls == [
|
||||
["/usr/bin/uv", "pip", "install", "-e", ".[termux-all]"],
|
||||
["/usr/bin/uv", "pip", "install", "-e", "."],
|
||||
["/usr/bin/uv", "pip", "install", "-e", ".[termux]"],
|
||||
["/usr/bin/uv", "pip", "install", "-e", ".[mcp]"],
|
||||
]
|
||||
|
||||
|
||||
def test_install_heartbeat_prints_when_dependency_install_is_silent(monkeypatch, capsys):
|
||||
"""Long quiet installs should emit periodic heartbeat lines."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue