Skip to content

The agent that grows with you

fix(ci): repair native Windows test coverage

ethernet7899760ff512
diff --git a/.github/workflows/tests-os.yml b/.github/workflows/tests-os.yml
index 8d7d8dd5954..19d1956a422 100644
--- a/.github/workflows/tests-os.yml
+++ b/.github/workflows/tests-os.yml
@@ -81,7 +81,7 @@ jobs:
- name: Set up locked Python and test dependencies
uses: ./.github/actions/setup-pm
with:
- extras: '["all", "dev", "anthropic", "mistral", "fal", "modal", "daytona", "hindsight", "parallel-web"]'
+ extras: '["all", "dev", "telegram", "anthropic", "mistral", "fal", "modal", "daytona", "hindsight", "parallel-web"]'
prune-python-cache: true
- name: Run ${{ matrix.marker }} tests
diff --git a/tests/agent/test_prompt_builder.py b/tests/agent/test_prompt_builder.py
index fa96e555b6f..b57b888c516 100644
--- a/tests/agent/test_prompt_builder.py
+++ b/tests/agent/test_prompt_builder.py
@@ -650,7 +650,11 @@ class TestFindHermesMd:
with patch("agent.prompt_builder._find_git_root", return_value=None):
assert _find_hermes_md(cwd) is None
- @pytest.mark.skipif(os.geteuid() == 0, reason="root bypasses directory permissions")
+ @pytest.mark.platforms("posix")
+ @pytest.mark.skipif(
+ getattr(os, "geteuid", lambda: -1)() == 0,
+ reason="root bypasses directory permissions",
+ )
def test_unreadable_cwd_is_treated_as_not_found(self, tmp_path):
"""A cwd the process cannot stat yields "no context file" instead of a PermissionError
escaping prompt construction and taking down every surface sharing the gateway (#112430:
@@ -692,7 +696,11 @@ class TestFindGitRoot:
class TestCursorrulesCandidates:
- @pytest.mark.skipif(os.geteuid() == 0, reason="root bypasses directory permissions")
+ @pytest.mark.platforms("posix")
+ @pytest.mark.skipif(
+ getattr(os, "geteuid", lambda: -1)() == 0,
+ reason="root bypasses directory permissions",
+ )
def test_unreadable_cwd_is_treated_as_absent(self, tmp_path):
"""Same crash shape as ``_find_hermes_md``: ``.is_dir()`` on ``<cwd>/.cursor/rules`` inside an
unreadable cwd must not raise; a readable sibling project still yields its rules."""
diff --git a/tests/ci/test_desktop_store_eligibility.py b/tests/ci/test_desktop_store_eligibility.py
index c1f5a40ad26..6ea0e6da53f 100644
--- a/tests/ci/test_desktop_store_eligibility.py
+++ b/tests/ci/test_desktop_store_eligibility.py
@@ -64,10 +64,11 @@ def test_native_windows_build_selects_store_only_for_stable(tmp_path, tag, commi
log = tmp_path / 'calls.txt'
powershell = shutil.which('powershell')
assert powershell
- result = subprocess.run([powershell, '-NoProfile', '-File', str(wrapper)],
+ result = subprocess.run([powershell, '-NoProfile', '-NonInteractive',
+ '-ExecutionPolicy', 'Bypass', '-File', str(wrapper)],
env=_child_env(HERMES_PAYLOAD_TAG=tag, HERMES_BUILD_COMMIT=commit,
RUNNER_TEMP=str(tmp_path), CALL_LOG=str(log)),
- capture_output=True, text=True, timeout=15)
+ capture_output=True, text=True, timeout=60)
assert result.returncode == 0, result.stdout + result.stderr
calls = log.read_text(encoding='utf-8-sig')
assert '--variant bundled' in calls
diff --git a/tests/gateway/test_control_socket_windows_live.py b/tests/gateway/test_control_socket_windows_live.py
index c8dc44576d4..796df02d02f 100644
--- a/tests/gateway/test_control_socket_windows_live.py
+++ b/tests/gateway/test_control_socket_windows_live.py
@@ -148,4 +148,5 @@ def test_pipe_gone_after_kill_falls_back(live_server, monkeypatch):
fleet = ur.collect_fleet_versions()
assert len(fleet) == 1, fleet
assert "source" not in fleet[0]
- assert fleet[0]["state"] == "stale"
+ assert fleet[0]["state"] == "unknown"
+ assert fleet[0]["code_sha"] is None
diff --git a/tests/gateway/test_telegram_closewait_windows_live.py b/tests/gateway/test_telegram_closewait_windows_live.py
index 70d4c4850bf..8fc3c017e22 100644
--- a/tests/gateway/test_telegram_closewait_windows_live.py
+++ b/tests/gateway/test_telegram_closewait_windows_live.py
@@ -242,10 +242,12 @@ async def test_drain_bounded_and_functional_when_close_wedges_live(monkeypatch):
old_client = polling_req._client # noqa: SLF001
_diag(server, "wedge-probe: after first round-trip")
- async def _wedged_shutdown():
+ async def _wedged_shutdown(_request):
await asyncio.Event().wait()
- monkeypatch.setattr(polling_req, "shutdown", _wedged_shutdown)
+ # PTB 22.8 slots HTTPXRequest instances, so the bound method is
+ # read-only. Patch the class seam for this one live request instead.
+ monkeypatch.setattr(HTTPXRequest, "shutdown", _wedged_shutdown)
monkeypatch.setattr(tg_adapter, "_DRAIN_TIMEOUT", 1.0)
adapter = _make_adapter()
diff --git a/tests/hermes_cli/test_plan_reconciliation_windows_live.py b/tests/hermes_cli/test_plan_reconciliation_windows_live.py
index 345407c5507..385eb4396d6 100644
--- a/tests/hermes_cli/test_plan_reconciliation_windows_live.py
+++ b/tests/hermes_cli/test_plan_reconciliation_windows_live.py
@@ -22,6 +22,7 @@ import pytest
pytestmark = pytest.mark.platforms("windows") # live Windows E2E
[email protected]_gateway_lookalike
def test_plan_reconciliation_live_windows(tmp_path, monkeypatch):
home = tmp_path / ".hermes"
home.mkdir()
@@ -29,7 +30,14 @@ def test_plan_reconciliation_live_windows(tmp_path, monkeypatch):
# Real live process standing in for a manual gateway
child = subprocess.Popen(
- [sys.executable, "-c", "import time; time.sleep(120)"],
+ [
+ sys.executable,
+ "-c",
+ "import time; time.sleep(120)",
+ "hermes_cli.main",
+ "gateway",
+ "run",
+ ],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
)
try:
diff --git a/tests/hermes_cli/test_update_target_identity.py b/tests/hermes_cli/test_update_target_identity.py
index 3b041b2cc23..31a885cc844 100644
--- a/tests/hermes_cli/test_update_target_identity.py
+++ b/tests/hermes_cli/test_update_target_identity.py
@@ -266,26 +266,28 @@ def test_stable_git_uses_remote_identity_without_moving_local_tags(update_tree,
@pytest.mark.platforms('windows')
[email protected]('transport', ['gitless', 'no-git', 'missing-release', 'missing-sha',
- 'git-error', 'moved-git-error', 'dirty'])
[email protected]('transport', ['gitless', 'no-git', 'git-error', 'dirty'])
def test_stable_zip_consumes_the_same_commit_through_the_real_swap(update_tree, monkeypatch, tmp_path, transport):
+ from hermes_cli import source_releases
+ from hermes_cli.release_channels import ChannelResolution
+
t = update_tree
+ monkeypatch.setattr(cli_main, '_pause_windows_gateways_for_update',
+ lambda: {"resume_needed": True})
archive = tmp_path / 'source.zip'
git(t.origin, 'archive', '--format=zip', '--prefix=hermes-agent-source/', f'--output={archive}', t.wanted)
archive_bytes = archive.read_bytes()
- latest = {'tag_name': 'v1.1.0', 'draft': False, 'prerelease': False}
+ record = {"schema": 1, "name": "stable", "repository": "NousResearch/hermes-agent",
+ "policy": "stable-release", "state": "active", "identity": {}, "nextSequence": 2,
+ "head": {"buildId": "build-fixture", "sequence": 1}}
+ manifest = {"schema": 1, "request": {"buildId": "build-fixture", "channel": "stable", "sequence": 1,
+ "repository": "NousResearch/hermes-agent", "commit": t.wanted, "sourceVersion": "1.1.0",
+ "version": "0.0.1", "identity": {}, "bundleEnv": {}}, "packages": []}
+ monkeypatch.setattr(source_releases, '_resolve_channel',
+ lambda name, repository: ChannelResolution(record, record, manifest))
routes = {
- '/repos/NousResearch/hermes-agent/releases/latest': latest,
- '/repos/NousResearch/hermes-agent/releases/tags/v1.1.0': latest,
- '/repos/NousResearch/hermes-agent/commits/v1.1.0': {'sha': t.wanted},
- '/repos/NousResearch/hermes-agent/tags?per_page=100': [{'name': 'v1.1.0', 'commit': {'sha': t.wanted}}],
f'/NousResearch/hermes-agent/archive/{t.wanted}.zip': archive_bytes,
}
- if transport == 'missing-release':
- routes.pop('/repos/NousResearch/hermes-agent/releases/latest')
- if transport == 'missing-sha':
- routes['/repos/NousResearch/hermes-agent/commits/v1.1.0'] = {'sha': 'not-a-commit'}
- routes.pop('/repos/NousResearch/hermes-agent/tags?per_page=100')
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
@@ -333,14 +335,11 @@ def test_stable_zip_consumes_the_same_commit_through_the_real_swap(update_tree,
failed = True
raise subprocess.CalledProcessError(128, command, '', 'fixture: Git file I/O failed')
result = real_run(command, *args, **kwargs)
- if 'ls-remote' in command and transport == 'moved-git-error':
- real_run(['git', '-c', 'tag.gpgSign=false', 'tag', '-fa', 'v1.1.0', t.newer, '-m', 'moved'],
- cwd=t.origin, check=True, capture_output=True)
if 'fetch' in command:
fetched = True
return result
- if transport in {'gitless', 'no-git', 'missing-release', 'missing-sha'}:
+ if transport in {'gitless', 'no-git'}:
(t.clone / '.git').rename(tmp_path / 'git-state')
if transport == 'dirty':
(t.clone / 'content.txt').write_text('local work\n', encoding='utf-8')
@@ -348,7 +347,7 @@ def test_stable_zip_consumes_the_same_commit_through_the_real_swap(update_tree,
monkeypatch.setattr(urllib.request, 'urlopen', local_open)
monkeypatch.setattr(subprocess, 'run', guarded_run)
try:
- if transport in {'missing-sha', 'missing-release', 'dirty'}:
+ if transport == 'dirty':
with pytest.raises(SystemExit) as error:
cli_main.cmd_update(t.args)
assert error.value.code == 1
@@ -368,10 +367,9 @@ def test_stable_zip_consumes_the_same_commit_through_the_real_swap(update_tree,
assert [url for url in urls if '/archive/' in url] == [
f'https://github.com/NousResearch/hermes-agent/archive/{t.wanted}.zip']
assert t.resumed
- if transport in {'git-error', 'moved-git-error', 'dirty'}:
+ if transport in {'git-error', 'dirty'}:
assert failed and fetched
- assert len([cmd for cmd in git_calls if 'ls-remote' in cmd]) == 1
- assert sum('/commits/' in url for url in urls) == 1
+ assert not any('ls-remote' in cmd for cmd in git_calls)
finally:
server.shutdown()
thread.join(timeout=5)