fix(tests): tolerate ps ancestor-walk in find_gateway_pids fallback test (#19590)

Follow-up to #19586 (@cixuuz salvage): _get_ancestor_pids walks ps -o ppid=
up the process tree, which the pre-existing mock in
test_find_gateway_pids_falls_back_to_pid_file_when_process_scan_fails didn't
expect. Return empty stdout so the ancestor loop terminates cleanly and the
original fallback assertion still passes.
This commit is contained in:
Teknium 2026-05-04 01:40:39 -07:00 committed by GitHub
parent 9c93fc5775
commit 06031229e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -310,6 +310,10 @@ def test_find_gateway_pids_falls_back_to_pid_file_when_process_scan_fails(monkey
def fake_run(cmd, **kwargs): def fake_run(cmd, **kwargs):
if cmd[:4] == ["ps", "-A", "eww", "-o"]: if cmd[:4] == ["ps", "-A", "eww", "-o"]:
return SimpleNamespace(returncode=1, stdout="", stderr="ps failed") return SimpleNamespace(returncode=1, stdout="", stderr="ps failed")
if cmd[:3] == ["ps", "-o", "ppid="]:
# _get_ancestor_pids() walks up the tree; return "no parent" so
# the loop terminates cleanly.
return SimpleNamespace(returncode=1, stdout="", stderr="")
raise AssertionError(f"Unexpected command: {cmd}") raise AssertionError(f"Unexpected command: {cmd}")
monkeypatch.setattr(gateway.subprocess, "run", fake_run) monkeypatch.setattr(gateway.subprocess, "run", fake_run)