`scripts/run_tests.sh tests/<dir>/` is how a change gets its regression
coverage run, so a test filed under the wrong directory is a test nobody
runs when that code changes. Two kinds of drift had accumulated.
Parallel directories for one source package, folded into the mirror:
tests/acp -> tests/acp_adapter (its __init__/conftest move with it)
tests/cli -> tests/hermes_cli (prompt_toolkit fixture merged into
hermes_cli/conftest.py)
tests/run_agent -> tests/agent (backoff fixture becomes
agent/conftest.py)
tests/relay -> tests/gateway/relay
tests/state -> tests/hermes_state
246 loose files at tests/ root, routed by the package they import/patch:
hermes_cli, hermes_state, agent, gateway, tools, plugins, tui_gateway, cron.
Installer and desktop-update script tests go to tests/scripts/{install,
desktop_update}/. 43 tests of root-level modules (batch_runner, utils,
hermes_constants, packaging) stay at the root.
Filenames drop their issue numbers (95 files: test_89315_x.py -> test_x.py);
the number stays in the module docstring where it has context.
Collisions: test_cli_skin_integration.py existed in both tests/ and tests/cli
with different subsets — merged into one (10 tests, all kept);
run_agent/test_pre_compress_memory_context.py -> agent/..._handoff.py;
tests/test_account_usage.py -> agent/test_account_usage_fetch.py;
tests/test_web_server.py -> hermes_cli/test_web_server_ws_ping.py.
Deleted: test_minisweagent_path.py (empty since PR #2804),
test_model_picker_scroll.py (tested a private copy of the logic, imported
nothing), test_process_loop_event_loop_warning.py (asserted asyncio behaviour,
imported nothing from Hermes).
Repo-root path arithmetic (Path(__file__).parents[N], dirname chains) is
bumped for the 202 files that changed depth and verified by evaluating every
such expression against the new location. classify_changes' desktop-updater
lane prefix, tests-os.yml's ignore glob and every in-tree path comment follow
the moves. tests/test_tests_tree_layout.py keeps the tree from drifting back.
73 lines
3.0 KiB
Python
73 lines
3.0 KiB
Python
"""Regression test for install.ps1 browser setup (PR #44772 review).
|
|
|
|
agent-browser resolves lazily via npx everywhere else in the system
|
|
(tools/browser_tool.py::_find_agent_browser); Install-AgentBrowser was the
|
|
last place that still eagerly npm-installed a second, separately
|
|
version-pinned copy of it. Removed: agent-browser acquisition now happens
|
|
only via `hermes update`'s npx cache warm or an actual browser-tool call's
|
|
lazy npx resolution.
|
|
|
|
Linux CI cannot execute the PowerShell installer, so verification here is
|
|
source-text-level only, matching tests/scripts/install/test_install_sh_browser_install.py
|
|
and tests/scripts/install/test_install_ps1_ascii_only.py.
|
|
"""
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parent.parent.parent.parent
|
|
INSTALL_PS1 = REPO_ROOT / "scripts" / "install.ps1"
|
|
|
|
|
|
def _extract_function_body(source: str, name: str) -> str:
|
|
m = re.search(
|
|
rf"^function {re.escape(name)} \{{.*?^\}}", source, re.MULTILINE | re.DOTALL
|
|
)
|
|
assert m, f"could not extract function {name} from install.ps1"
|
|
return m.group(0)
|
|
|
|
|
|
def test_install_agent_browser_no_longer_npm_installs_agent_browser() -> None:
|
|
body = _extract_function_body(INSTALL_PS1.read_text(), "Install-AgentBrowser")
|
|
|
|
assert "agent-browser@" not in body
|
|
assert "Installing Chromium via agent-browser install" not in body
|
|
# camofox is unrelated to this change and must still be installed here.
|
|
assert "@askjo/camofox-browser@^1.5.2" in body
|
|
# System-browser detection is still cheap/valuable without agent-browser.
|
|
assert "Find-SystemBrowser" in body
|
|
assert "Write-BrowserEnv" in body
|
|
|
|
|
|
def test_install_agent_browser_drops_unused_skip_chromium_param() -> None:
|
|
"""$SkipChromium only existed to gate the now-removed Chromium-download
|
|
branch; grep confirms it's never passed at the one real call site, so a
|
|
lingering param would be dead code implying a control path that no
|
|
longer exists."""
|
|
body = _extract_function_body(INSTALL_PS1.read_text(), "Install-AgentBrowser")
|
|
|
|
assert "SkipChromium" not in body
|
|
|
|
# And the one real call site must not pass it either.
|
|
text = INSTALL_PS1.read_text()
|
|
call_site = re.search(r"^\s*Install-AgentBrowser.*$", text, re.MULTILINE)
|
|
assert call_site, "could not find Install-AgentBrowser call site"
|
|
assert "SkipChromium" not in call_site.group(0)
|
|
|
|
|
|
def test_install_agent_browser_still_ignore_scripts_hardened() -> None:
|
|
"""The removal of agent-browser must not have also dropped the
|
|
supply-chain hardening that still applies to the remaining camofox
|
|
install."""
|
|
body = _extract_function_body(INSTALL_PS1.read_text(), "Install-AgentBrowser")
|
|
|
|
assert "--ignore-scripts" in body
|
|
|
|
|
|
def test_install_agent_browser_no_longer_references_agent_browser_cmd_shim() -> None:
|
|
"""No dangling reference to the agent-browser.cmd shim should remain
|
|
now that this function never installs it."""
|
|
body = _extract_function_body(INSTALL_PS1.read_text(), "Install-AgentBrowser")
|
|
|
|
assert "agent-browser.cmd" not in body
|