upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbbareth <179921368+BBareth@users.noreply.github.com>2026-11-22 23:56:00 +0100
committerbbareth <179921368+BBareth@users.noreply.github.com>2026-11-22 23:56:00 +0100
commit6d3b3f9f4e524381cc059d3369ad8a97bbc585db (patch)
tree54c33d1a1cbd4edad21c6cfa644752420df8af35
parentaa2988cc555bad7ecd508b48a702adbb32fe7c95 (diff)
Handle malformed CTest skip codes in the Wine runner
-rw-r--r--scripts/run_wine_tests.py12
-rw-r--r--tests/test_run_wine_tests.py20
2 files changed, 30 insertions, 2 deletions
diff --git a/scripts/run_wine_tests.py b/scripts/run_wine_tests.py
index 3e90e9ab4..b3427a2ab 100644
--- a/scripts/run_wine_tests.py
+++ b/scripts/run_wine_tests.py
@@ -161,6 +161,15 @@ def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]:
161 return "fail", "invalid CTest TIMEOUT" 161 return "fail", "invalid CTest TIMEOUT"
162 if ctest_timeout > 0: 162 if ctest_timeout > 0:
163 timeout = min(timeout, ctest_timeout) 163 timeout = min(timeout, ctest_timeout)
164 skip_code = props.get("SKIP_RETURN_CODE")
165 if skip_code is not None:
166 error = "invalid CTest SKIP_RETURN_CODE: expected an integer from 0 to 255"
167 try:
168 skip_code = int(str(skip_code))
169 except ValueError:
170 return "fail", error
171 if not 0 <= skip_code <= 255:
172 return "fail", error
164 start = time.monotonic() 173 start = time.monotonic()
165 try: 174 try:
166 proc = subprocess.run(argv, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 175 proc = subprocess.run(argv, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
@@ -177,8 +186,7 @@ def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]:
177 # A negative return code is a host-signal termination (e.g. SIGSEGV), not a process exit code: 186 # A negative return code is a host-signal termination (e.g. SIGSEGV), not a process exit code:
178 # report it as a failure before SKIP_RETURN_CODE or WILL_FAIL can reinterpret it. 187 # report it as a failure before SKIP_RETURN_CODE or WILL_FAIL can reinterpret it.
179 return "fail", f"killed by signal {-code} in {elapsed:.1f} s\n{out}" 188 return "fail", f"killed by signal {-code} in {elapsed:.1f} s\n{out}"
180 skip_code = props.get("SKIP_RETURN_CODE") 189 if code == skip_code:
181 if skip_code is not None and code == int(skip_code):
182 return "skip", f"exit {code} (skip) in {elapsed:.1f} s\n{out}" 190 return "skip", f"exit {code} (skip) in {elapsed:.1f} s\n{out}"
183 detail = f"exit {code} in {elapsed:.1f} s\n{out}" 191 detail = f"exit {code} in {elapsed:.1f} s\n{out}"
184 skip_patterns = regex_list(props.get("SKIP_REGULAR_EXPRESSION", [])) 192 skip_patterns = regex_list(props.get("SKIP_REGULAR_EXPRESSION", []))
diff --git a/tests/test_run_wine_tests.py b/tests/test_run_wine_tests.py
index c45b2cc88..734611ee8 100644
--- a/tests/test_run_wine_tests.py
+++ b/tests/test_run_wine_tests.py
@@ -164,6 +164,15 @@ class RunTestTest(unittest.TestCase):
164 self.assertEqual(status, "skip") 164 self.assertEqual(status, "skip")
165 self.assertIn("exit 77", detail) 165 self.assertIn("exit 77", detail)
166 166
167 def test_invalid_skip_return_codes_fail_before_launch(self):
168 command = self.command_for(self.exiting(0))
169 for value in ("invalid", True, 1.5, -1, 256):
170 with self.subTest(value=value), mock.patch.object(rwt.subprocess, "run") as launch:
171 status, detail = self.run_entry(ctest_entry("invalid", command, {"SKIP_RETURN_CODE": value}))
172 self.assertEqual(status, "fail")
173 self.assertIn("invalid CTest SKIP_RETURN_CODE", detail)
174 launch.assert_not_called()
175
167 def test_ctest_environment_is_applied_only_to_its_child(self) -> None: 176 def test_ctest_environment_is_applied_only_to_its_child(self) -> None:
168 exe = self.program("show_environment.py", 177 exe = self.program("show_environment.py",
169 "import os\n" 178 "import os\n"
@@ -418,6 +427,17 @@ class MainTest(unittest.TestCase):
418 self.assertEqual(code, 0) 427 self.assertEqual(code, 0)
419 self.assertIn("[FAIL] bad", out) 428 self.assertIn("[FAIL] bad", out)
420 429
430 def test_malformed_skip_return_code_does_not_stop_later_tests(self):
431 entries = [
432 ctest_entry("bad_property", self.command("ok.py"), {"SKIP_RETURN_CODE": "invalid"}),
433 ctest_entry("ok", self.command("ok.py")),
434 ]
435 code, out, err = self.run_main(entries, "--require", "ok")
436 self.assertEqual(code, 0, err)
437 self.assertIn("[FAIL] bad_property", out)
438 self.assertIn("invalid CTest SKIP_RETURN_CODE", out)
439 self.assertIn("[PASS] ok", out)
440
421 def test_the_summary_table_is_appended(self): 441 def test_the_summary_table_is_appended(self):
422 summary = self.root / "summary.md" 442 summary = self.root / "summary.md"
423 code, _, _ = self.run_main([ctest_entry("ok", self.command("ok.py")), ctest_entry("bad", self.command("bad.py"))], 443 code, _, _ = self.run_main([ctest_entry("ok", self.command("ok.py")), ctest_entry("bad", self.command("bad.py"))],