From 39b30e15365756ae685e02b5af38799a677858af Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 2 Aug 2020 09:35:12 -0400 Subject: In TestSpawn.test_concurrent_safe, use CheckThread to ensure that the spawn call does not simply fail to execute. Ref pypa/setuptools#2257. --- distutils/tests/test_msvccompiler.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/distutils/tests/test_msvccompiler.py b/distutils/tests/test_msvccompiler.py index f4bb5162..88d912b1 100644 --- a/distutils/tests/test_msvccompiler.py +++ b/distutils/tests/test_msvccompiler.py @@ -76,6 +76,19 @@ class msvccompilerTestCase(support.TempdirManager, raise unittest.SkipTest("VS 2015 is not installed") +class CheckThread(threading.Thread): + exc_info = None + + def run(self): + try: + super().run() + except Exception: + self.exc_info = sys.exc_info() + + def __bool__(self): + return not self.exc_info + + class TestSpawn(unittest.TestCase): def test_concurrent_safe(self): """ @@ -88,13 +101,14 @@ class TestSpawn(unittest.TestCase): command = ['python', '-c', inner_cmd] threads = [ - threading.Thread(target=compiler.spawn, args=[command]) + CheckThread(target=compiler.spawn, args=[command]) for n in range(100) ] for thread in threads: thread.start() for thread in threads: thread.join() + assert all(threads) def test_suite(): -- cgit v1.2.3