test: harden yolo and kanban signal tests on macOS
Autouse fixture also resets approval_module._YOLO_MODE_FROZEN so a HERMES_YOLO_MODE=1 host env can't poison every case (the one startup-frozen test still patches it back explicitly). Adds the darwin 'ps -o stat=' zombie branch to _is_alive_like_dispatcher, mirroring production hermes_cli/kanban_db.py — a no-op on Linux. Salvaged from PR #34069 by @sunwz1115. Co-authored-by: sunwz1115 <192549904+sunwz1115@users.noreply.github.com>
This commit is contained in:
parent
3e7a11ca2e
commit
230a2c273e
|
|
@ -40,6 +40,11 @@ SESSION_KEY = "test-cli-yolo-session"
|
|||
def _clear_approval_state(monkeypatch):
|
||||
"""Clear the YOLO bypass + env var around every test so cases are independent."""
|
||||
monkeypatch.delenv("HERMES_YOLO_MODE", raising=False)
|
||||
# The value is intentionally frozen at tools.approval import time. Local
|
||||
# Hermes-driven test runs may inherit HERMES_YOLO_MODE=1 from the parent
|
||||
# agent process, so make the default test state hermetic; the one test that
|
||||
# covers startup-frozen YOLO explicitly patches it back to True.
|
||||
monkeypatch.setattr(approval_module, "_YOLO_MODE_FROZEN", False)
|
||||
approval_module.clear_session(SESSION_KEY)
|
||||
approval_module.clear_session("default")
|
||||
yield
|
||||
|
|
|
|||
|
|
@ -103,6 +103,22 @@ def _is_alive_like_dispatcher(pid: int) -> bool:
|
|||
break
|
||||
except (FileNotFoundError, PermissionError, OSError):
|
||||
pass
|
||||
elif sys.platform == "darwin":
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
["ps", "-o", "stat=", "-p", str(pid)],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL,
|
||||
text=True,
|
||||
timeout=1,
|
||||
check=False,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
return False
|
||||
if "Z" in (proc.stdout or "").strip():
|
||||
return False
|
||||
except (OSError, subprocess.SubprocessError, TimeoutError):
|
||||
pass
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue