Skip to content

The agent that grows with you

test(process): owned-child tests wait with tests.waiting.wait_until and run the Windows case natively

kshitijk4poorbcc1f11f1cda
diff --git a/tests/hermes_cli/test_process_identity_release_once_empty.py b/tests/hermes_cli/test_process_identity_release_once_empty.py
index 6915c9e18b9..c381a6919c1 100644
--- a/tests/hermes_cli/test_process_identity_release_once_empty.py
+++ b/tests/hermes_cli/test_process_identity_release_once_empty.py
@@ -3,16 +3,12 @@
import os
import signal
import subprocess
-import sys
import threading
import pytest
from hermes_cli import process_identity
-pytestmark = pytest.mark.platforms("posix")
-
-
@pytest.fixture
def released(monkeypatch):
calls: list = []
@@ -25,6 +21,7 @@ def _leader(script: str) -> subprocess.Popen:
start_new_session=True) # detached-spawn: ok — test stand-in, killed in finally
def test_an_empty_group_is_released_even_with_an_unreaped_leader(released):
leader = _leader("exit 0")
# Not wait()ed: the zombie leader keeps killpg(pgid, 0) succeeding until proc.poll() reaps it.
@@ -32,6 +29,7 @@ def test_an_empty_group_is_released_even_with_an_unreaped_leader(released):
assert released == [[leader.pid]]
def test_a_group_with_a_live_member_stays_covered(released):
leader = _leader("trap '' TERM; exec sleep 60")
try:
@@ -42,6 +40,7 @@ def test_a_group_with_a_live_member_stays_covered(released):
leader.wait(timeout=10)
def test_it_waits_for_a_member_that_exits_late(released):
leader = _leader("exec sleep 60")
threading.Timer(0.3, lambda: os.killpg(leader.pid, signal.SIGKILL)).start() # windows-footgun: ok — posix-marked test
@@ -54,7 +53,8 @@ def test_it_waits_for_a_member_that_exits_late(released):
leader.wait(timeout=10)
-def test_windows_never_releases(monkeypatch, released):
- monkeypatch.setattr(process_identity.os, "name", "nt")
- assert not process_identity.release_process_group_once_empty(sys.maxsize, timeout=0)
+def test_windows_never_releases(released):
+ """Windows children die through the job object; there is no supervised group to release."""
+ assert not process_identity.release_process_group_once_empty(os.getpid(), timeout=0)
assert released == []
diff --git a/tests/hermes_cli/test_process_identity_supervisor.py b/tests/hermes_cli/test_process_identity_supervisor.py
index 9ac01a03188..0ef0713b21b 100644
--- a/tests/hermes_cli/test_process_identity_supervisor.py
+++ b/tests/hermes_cli/test_process_identity_supervisor.py
@@ -19,6 +19,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
import pytest
+from tests.waiting import wait_until
+
from hermes_cli import process_identity
from tools import mcp_tool
from tools import mcp_tool_lifecycle as _mcp_lifecycle
@@ -45,12 +47,11 @@ def _alive(pid: int) -> bool:
def _wait_gone(pid: int, timeout: float = 15.0) -> bool:
"""Wait for a process this test does NOT own to disappear."""
- deadline = time.monotonic() + timeout
- while time.monotonic() < deadline:
- if not _alive(pid):
- return True
- time.sleep(0.05)
- return False
+ try:
+ wait_until(lambda: not _alive(pid), timeout=timeout)
+ except AssertionError:
+ return False
+ return True
def _wait_exited(proc: subprocess.Popen, timeout: float = 15.0) -> bool: