From 1916009df116344d90e3970593db47028a9ca96a Mon Sep 17 00:00:00 2001 From: Aaron Jomy Date: Tue, 8 Sep 2026 17:36:47 +0200 Subject: [PATCH] [test] Record and assert thread failures in the overload-reuse test --- test/test_concurrent.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/test_concurrent.py b/test/test_concurrent.py index 026fdcc..cfafb3f 100644 --- a/test/test_concurrent.py +++ b/test/test_concurrent.py @@ -251,10 +251,17 @@ class Simulation1 { virtual void set_something(std::map, std::string) {} }; }""") + # A thread that dies with an exception only warns; collect and + # assert instead, so conversion clashes actually fail the test. + failures = [] + def test(): - o = {"a": "b"} # causes a temporary to be created - simulation = cppjit.gbl.CPPOverloadReuse.Simulation1() - simulation.set_something(o, ".") + try: + o = {"a": "b"} # causes a temporary to be created + simulation = cppjit.gbl.CPPOverloadReuse.Simulation1() + simulation.set_something(o, ".") + except Exception as e: + failures.append(e) threads = [threading.Thread(target=test) for i in range(0, 100)] @@ -264,6 +271,10 @@ def test(): for t in threads: t.join() + assert not failures, ( + f"{len(failures)} of {len(threads)} threads failed: {failures[0]}" + ) + def test07_overload_reuse_in_threads_wo_gil(self): """Threads reuse overload objects; check for clashes if no GIL"""