From bb7bfefa29132c0c511c5e07a944272ae0f2efdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davor=20Raci=C4=87?= Date: Sun, 26 Jul 2026 13:50:12 +0200 Subject: [PATCH 1/2] fix(tests): remove hardcoded GNU coreutils dependencies on Windows (#293) --- tests/test_cleanup.py | 3 ++- tests/test_runs.py | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/test_cleanup.py b/tests/test_cleanup.py index 16256998..ca6e91d7 100644 --- a/tests/test_cleanup.py +++ b/tests/test_cleanup.py @@ -3,6 +3,7 @@ import argparse import subprocess +import sys from conftest import install_bmad_config, machine_json @@ -22,7 +23,7 @@ def _state_run(project, run_id, **kw): def _dead_pid() -> int: - p = subprocess.Popen(["true"]) + p = subprocess.Popen([sys.executable, "-c", ""]) p.wait() return p.pid diff --git a/tests/test_runs.py b/tests/test_runs.py index badffe78..3f5ff709 100644 --- a/tests/test_runs.py +++ b/tests/test_runs.py @@ -405,12 +405,17 @@ def test_stop_run_dead_pid_falls_back(tmp_path, monkeypatch): def test_stop_run_signals_live_process(tmp_path, monkeypatch): monkeypatch.setattr(runs, "kill_session", lambda _rid: None) run_dir = _make_state_run(tmp_path, "r1") - proc = subprocess.Popen(["sleep", "30"]) - (run_dir / "engine.pid").write_text(str(proc.pid)) - assert runs.stop_run(run_dir) is True - # the process received SIGTERM and is gone - assert proc.poll() is not None or proc.wait(timeout=5) is not None - assert load_state(run_dir).stopped is True + proc = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(30)"]) + try: + (run_dir / "engine.pid").write_text(str(proc.pid)) + assert runs.stop_run(run_dir) is True + # the process received SIGTERM and is gone + assert proc.poll() is not None or proc.wait(timeout=5) is not None + assert load_state(run_dir).stopped is True + finally: + if proc.poll() is None: + proc.kill() + proc.wait() def test_stop_run_respects_engine_written_stopped(tmp_path, monkeypatch): From 6454a6ad6d72600b5636818af11202358a4d12ee Mon Sep 17 00:00:00 2001 From: pbean Date: Sun, 26 Jul 2026 13:25:38 -0700 Subject: [PATCH 2/2] fix(tests): delete the uncalled _dead_pid copy (#293 review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_cleanup.py's _dead_pid has never had a call site: 62818ed created the file by copying the helper out of test_runs.py — `Popen(["true"])` body and all — but never wrote one, and the count has stayed at the bare `def` ever since. So it was not part of #293's failure set: an uncalled helper cannot resolve `true` on any PATH, which is also why #31 fixed only the live copy when it added the native-Windows lane, and why three weeks of that lane never flagged it. Porting it would re-apply #31's fix to code that never runs and re-sync a duplicate of test_runs.py:42 — recreating the duplication that let it drift. Delete it and its now-unused `import subprocess` instead; the coreutils dependency goes away either way. Also bound the new cleanup `wait()` in test_stop_run_signals_live_process, which every other wait in that file and in test_process_host.py already does. --- tests/test_cleanup.py | 8 -------- tests/test_runs.py | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/test_cleanup.py b/tests/test_cleanup.py index ca6e91d7..084c5dc1 100644 --- a/tests/test_cleanup.py +++ b/tests/test_cleanup.py @@ -2,8 +2,6 @@ artifact trim, and the `clean` CLI command.""" import argparse -import subprocess -import sys from conftest import install_bmad_config, machine_json @@ -22,12 +20,6 @@ def _state_run(project, run_id, **kw): return run_dir -def _dead_pid() -> int: - p = subprocess.Popen([sys.executable, "-c", ""]) - p.wait() - return p.pid - - # --------------------------------------------------------------- predicates diff --git a/tests/test_runs.py b/tests/test_runs.py index 3f5ff709..ca1f6f26 100644 --- a/tests/test_runs.py +++ b/tests/test_runs.py @@ -415,7 +415,7 @@ def test_stop_run_signals_live_process(tmp_path, monkeypatch): finally: if proc.poll() is None: proc.kill() - proc.wait() + proc.wait(timeout=10) def test_stop_run_respects_engine_written_stopped(tmp_path, monkeypatch):