Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions tests/test_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
artifact trim, and the `clean` CLI command."""

import argparse
import subprocess

from conftest import install_bmad_config, machine_json

Expand All @@ -21,12 +20,6 @@ def _state_run(project, run_id, **kw):
return run_dir


def _dead_pid() -> int:
p = subprocess.Popen(["true"])
p.wait()
return p.pid


# --------------------------------------------------------------- predicates


Expand Down
17 changes: 11 additions & 6 deletions tests/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(timeout=10)


def test_stop_run_respects_engine_written_stopped(tmp_path, monkeypatch):
Expand Down