diff --git a/CHANGELOG.md b/CHANGELOG.md index f8c67069..17f0d9d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,15 @@ PyPI version — not the changelog header. ### Fixed +- **Two more non-hermetic ai_mail tests made deterministic (PR659).** With the full + suite now running on varied CI runners, `test_get_pid_cwd_darwin_failure` and + `test_is_zombie_linux_no_proc` intermittently failed: they called the real `lsof` + (via `subprocess.run`) and real `open("/proc/…")` for a fixed PID (999 / 99999), + so on a runner where that PID happened to exist they returned a non-`None` result + instead of the expected failure. Mocked `subprocess.run` and `builtins.open` so the + tests assert the failure contract without touching real process/`/proc` state. + Test-only; deterministic across repeated runs. + - **Windows CI cross-platform fixes — `windows-setup` green (PR659).** Fixing the telegram collection errors unmasked 14 pre-existing Windows-only failures across six branches. Two root causes. **(1) pid-liveness tests** (ai_mail, flow, hooks, diff --git a/src/aipass/ai_mail/tests/test_wake.py b/src/aipass/ai_mail/tests/test_wake.py index a36c1a01..00063866 100644 --- a/src/aipass/ai_mail/tests/test_wake.py +++ b/src/aipass/ai_mail/tests/test_wake.py @@ -273,6 +273,12 @@ def test_get_pid_cwd_darwin(monkeypatch, tmp_path): def test_get_pid_cwd_darwin_failure(monkeypatch): """macOS: lsof failure returns None.""" + + class FailedResult: + returncode = 1 + stdout = "" + + monkeypatch.setattr(subprocess, "run", lambda *a, **kw: FailedResult()) assert _get_pid_cwd_darwin("999") is None @@ -309,6 +315,14 @@ def test_is_zombie_linux_zombie(monkeypatch, tmp_path): def test_is_zombie_linux_no_proc(monkeypatch): """Missing /proc entry returns False (not zombie, just gone).""" + _real_open = open + + def _fake_open(path, *a, **kw): + if "/proc/99999/" in str(path): + raise FileNotFoundError(path) + return _real_open(path, *a, **kw) + + monkeypatch.setattr("builtins.open", _fake_open) assert _is_zombie_linux(99999) is False