From 7033a98aa8d7471efe44a2e2b138cb8e468a3ea9 Mon Sep 17 00:00:00 2001 From: KarthikNambiar04 Date: Thu, 17 Sep 2026 14:09:44 +0530 Subject: [PATCH] tests: fake os.killpg/signal.SIGKILL for Windows in remote-job test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_timeout_terminates_process_group_and_its_owned_containers mocks both Popen and killpg to exercise execute()'s timeout/cleanup state machine without touching a real OS. Neither os.killpg nor signal.SIGKILL exists on Windows, so monkeypatch.setattr's default raising=True failed before the fake was even installed. execute() only ever runs for real inside a Linux remote worker (REPO2RLENV_REMOTE_WORKER=1, killpg needs a POSIX process group), so this doesn't change production code — it lets the existing coverage of that logic run from a Windows host too, same shape as the os.chown guards in #136. --- tests/test_remote_job.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_remote_job.py b/tests/test_remote_job.py index bb425e3b..24e1abbb 100644 --- a/tests/test_remote_job.py +++ b/tests/test_remote_job.py @@ -32,7 +32,12 @@ def start(command, **kwargs): return Process() monkeypatch.setattr(job.subprocess, "Popen", start) - monkeypatch.setattr(job.os, "killpg", lambda *args: calls.append(args)) + # raising=False: neither os.killpg nor signal.SIGKILL exists on Windows. + # execute() only ever runs for real inside a Linux remote worker; both are + # faked here so the supervisor's timeout/cleanup logic can be verified + # from any host OS. + monkeypatch.setattr(job.os, "killpg", lambda *args: calls.append(args), raising=False) + monkeypatch.setattr(job.signal, "SIGKILL", 9, raising=False) monkeypatch.setattr(job, "_cleanup_containers", lambda token: {"passed": True, "removed": 1}) with pytest.raises(subprocess.TimeoutExpired): job.execute(tmp_path, ["remote-test-fixture"], timeout_sec=1)