Files
hermes-agent/tests/computer_use/test_permissions_resolution.py
ethernet 30da5d0a89 test: run os-specific tests on their real host, not a faked one
many tests patched sys.platform or a module's _IS_WINDOWS flag, then
ran on linux ci. the patch selects the branch under test, but the host
does not have the behavior the branch exists for. the test proves the
patch, not the platform. some gated assertions never ran on any host.

this commit adds three markers: linux_only, macos_only, windows_only.
a conftest hook skips a marked test on the other hosts, with a clear
reason. no test fakes a host now. two documented fakes remain
(android/termux, freebsd) because no ci runner exists for them.

each fake site got one of four treatments:
- gate it: the real host supplies the platform; mocks cover real
  dependencies only, never host identity
- patch the module's own probe when the subject is the probe's consumer
- assert against the real host when the fake stood in for any non-x host
- delete the patch when it set the value the host already has

bare skipif(sys.platform != ...) guards became markers too. the lane
model skips these on linux and never imports them on windows, so they
ran on no host. platform parametrize tables are now one marked test
per os.

running on real hosts found real errors: a chrome-sandbox failure in
test_gui_command that main hides, and two windows failures fixed here.
the agents.md testing section now documents the policy.
2026-08-09 22:09:49 -04:00

33 lines
1.2 KiB
Python

"""Regression tests for Computer Use readiness under a thin GUI PATH."""
from __future__ import annotations
import sys
from unittest.mock import MagicMock, patch
import pytest
@pytest.mark.skipif(sys.platform == "win32", reason="POSIX user-local path regression")
def test_status_finds_user_local_driver_when_path_omits_it(tmp_path, monkeypatch):
"""Desktop status must agree with the runtime resolver, not bare PATH."""
from tools.computer_use import permissions
driver = tmp_path / ".local" / "bin" / "cua-driver"
driver.parent.mkdir(parents=True)
driver.write_text("#!/bin/sh\nexit 0\n")
driver.chmod(0o755)
monkeypatch.delenv("HERMES_CUA_DRIVER_CMD", raising=False)
monkeypatch.setenv("HOME", str(tmp_path))
monkeypatch.setenv("PATH", "/usr/bin:/bin:/usr/sbin:/sbin")
# No platform faking: ``~/.local/bin/cua-driver`` is a POSIX resolution
# candidate on Linux exactly as on macOS, so the regression reproduces on
# the host we actually run on.
with patch.object(permissions, "_run", return_value=MagicMock(stdout="0.0.0")), \
patch.object(permissions, "_doctor", return_value={"ok": True, "checks": []}):
status = permissions.computer_use_status()
assert status["installed"] is True