changeset 51995:23cc79e04c28

tests: teach `killdaemons` on Windows to use an exit code provided by a caller Right now, there are several tests that use `signal.SIGKILL`, which isn't a thing on Windows. The `killdaemons` script approximates this by forcibly terminating the process. There's a minor difference in that `signal.SIGKILL` results in the test capturing an exit code of 137, and the `killdaemons` victim doesn't record a code (as though it exited with 0). Since the exit code line couldn't be conditionalized the last time I checked, let's just allow the caller to simulate the same exit code, and avoid conditionalizing the tests.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 12 Oct 2024 15:22:03 -0400
parents baf9e3a8fd14
children 625cf9621551
files tests/killdaemons.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/killdaemons.py	Thu Oct 10 17:55:50 2024 +0200
+++ b/tests/killdaemons.py	Sat Oct 12 15:22:03 2024 -0400
@@ -56,7 +56,12 @@
             if r == WAIT_OBJECT_0:
                 pass  # terminated, but process handle still available
             elif r == WAIT_TIMEOUT:
-                _check(ctypes.windll.kernel32.TerminateProcess(handle, -1))
+                # Allow the caller to optionally specify the exit code, to
+                # simulate killing with a signal.
+                exit_code = int(os.environ.get("DAEMON_EXITCODE", -1))
+                _check(
+                    ctypes.windll.kernel32.TerminateProcess(handle, exit_code)
+                )
             elif r == WAIT_FAILED:
                 _check(0)  # err stored in GetLastError()