The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(windows): restart watcher and desktop freshness follow PM ownership
ethernete89910154262
diff --git a/tests/gateway/test_restart_drain.py b/tests/gateway/test_restart_drain.pyindex fda427c7337..730113097b1 100644--- a/tests/gateway/test_restart_drain.py+++ b/tests/gateway/test_restart_drain.py@@ -273,14 +273,10 @@ async def test_windows_detached_restart_scrubs_gateway_marker(monkeypatch, tmp_pthis runs on the Windows CI job instead."""runner, _adapter = make_restart_runner()popen_calls = []- venv_dir = tmp_path / "venv"- site_packages = venv_dir / "Lib" / "site-packages"- site_packages.mkdir(parents=True)monkeypatch.setattr(gateway_run, "_resolve_hermes_bin", lambda: ["hermes"])monkeypatch.setattr(gateway_run.os, "getpid", lambda: 321)monkeypatch.setenv("_HERMES_GATEWAY", "1")- monkeypatch.setenv("VIRTUAL_ENV", str(venv_dir))import hermes_cli._subprocess_compat as subprocess_compat@@ -302,8 +298,11 @@ async def test_windows_detached_restart_scrubs_gateway_marker(monkeypatch, tmp_pcmd, kwargs = popen_calls[0]assert cmd[-3:] == ["hermes", "gateway", "restart"]assert kwargs["env"].get("_HERMES_GATEWAY") is None- assert kwargs["env"]["VIRTUAL_ENV"] == str(venv_dir)- assert str(site_packages) in kwargs["env"]["PYTHONPATH"].split(gateway_run.os.pathsep)+ # The watcher is an installation-bound command: PM's bootstrap selects the+ # dependency generation at child start, no venv is captured in its env.+ from hermes_cli._launchers import runtime_command+ from pathlib import Path+ assert cmd[:3] == runtime_command(Path(gateway_run.__file__).resolve().parent.parent)[:3]assert kwargs["stdout"] is subprocess.DEVNULLassert kwargs["stderr"] is subprocess.DEVNULLdiff --git a/tests/hermes_cli/test_desktop_startup_cost.py b/tests/hermes_cli/test_desktop_startup_cost.pyindex a81caa5d5ee..fbe36d5a562 100644--- a/tests/hermes_cli/test_desktop_startup_cost.py+++ b/tests/hermes_cli/test_desktop_startup_cost.py@@ -1,4 +1,6 @@-"""Startup regressions exercised against real source trees on the current host."""+"""Startup regressions exercised against real source trees on the current host.++Source freshness itself is the compiler's receipt (scripts/build/freshness.mjs), covered in tests-js."""import argparseimport os@@ -24,76 +26,6 @@ def _tree(tmp_path):return root, app, source-def test_desktop_hash_prunes_ignored_build_directories(tmp_path):- root, app, _ = _tree(tmp_path)- ignored = app / "dist"- ignored.mkdir()- (ignored / "bundle.js").write_text("built output")- expected = desktop._compute_desktop_content_hash(root)- original_scandir = os.scandir-- def scan(directory):- assert Path(directory) != ignored, "ignored build output must be pruned before traversal"- return original_scandir(directory)-- (ignored / "bundle.js").write_text("different build output")- with patch("os.scandir", side_effect=scan):- assert desktop._compute_desktop_content_hash(root) == expected---def test_desktop_hash_invalidates_for_edits_even_with_restored_mtime(tmp_path):- root, app, source = _tree(tmp_path)- original = desktop._compute_desktop_content_hash(root)- stamp = source.stat()- source.write_text("export const x = 2") # Same length; editors can preserve mtime.- os.utime(source, ns=(stamp.st_atime_ns, stamp.st_mtime_ns))- assert desktop._compute_desktop_content_hash(root) != original- source.write_text("export const x = 1")- assert desktop._compute_desktop_content_hash(root) == original- added = app / "new.ts"- added.write_text("new module")- assert desktop._compute_desktop_content_hash(root) != original- added.unlink()- assert desktop._compute_desktop_content_hash(root) == original- (root / "package.json").write_text('{"changed": true}')- assert desktop._compute_desktop_content_hash(root) != original--[email protected]("windows")-def test_desktop_hash_detects_memory_mapped_edits(tmp_path):- import mmap-- root, _, source = _tree(tmp_path)- original = desktop._compute_desktop_content_hash(root)- with source.open("r+b") as stream:- with mmap.mmap(stream.fileno(), 0, access=mmap.ACCESS_WRITE) as view:- view[-1:] = b"2"- view.flush()- assert source.read_bytes().endswith(b"2")- assert desktop._compute_desktop_content_hash(root) != original--[email protected]("windows")-def test_desktop_hash_recovers_after_a_temporary_read_lock(tmp_path):- import msvcrt-- root, _, source = _tree(tmp_path)- source.write_bytes(b"")- original = desktop._compute_desktop_content_hash(root)- payload = b"export const x = 2"- source.write_bytes(payload)- with source.open("r+b") as locked:- msvcrt.locking(locked.fileno(), msvcrt.LK_NBLCK, len(payload))- try:- with pytest.raises(OSError):- source.read_bytes()- desktop._compute_desktop_content_hash(root)- finally:- locked.seek(0)- msvcrt.locking(locked.fileno(), msvcrt.LK_UNLCK, len(payload))- assert desktop._compute_desktop_content_hash(root) != original--def test_current_packaged_launch_does_not_require_npm(tmp_path, monkeypatch):root, app, _ = _tree(tmp_path)monkeypatch.setattr(cli_main, "PROJECT_ROOT", root)@@ -111,3 +43,4 @@ def test_current_packaged_launch_does_not_require_npm(tmp_path, monkeypatch):assert exited.value.code == 0npm.assert_not_called()run.assert_called_once()+