diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-08-02 09:35:12 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2020-08-02 09:35:12 -0400 |
commit | 39b30e15365756ae685e02b5af38799a677858af (patch) | |
tree | 6a7ba2fe5ff51b2fee63e4ecfe51af3cf5d29607 | |
parent | 7f233974b0e3dc3692c820a2c8c3439c4d15fc70 (diff) | |
download | external_python_setuptools-39b30e15365756ae685e02b5af38799a677858af.tar.gz external_python_setuptools-39b30e15365756ae685e02b5af38799a677858af.tar.bz2 external_python_setuptools-39b30e15365756ae685e02b5af38799a677858af.zip |
In TestSpawn.test_concurrent_safe, use CheckThread to ensure that the spawn call does not simply fail to execute. Ref pypa/setuptools#2257.
-rw-r--r-- | distutils/tests/test_msvccompiler.py | 16 |
1 files changed, 15 insertions, 1 deletions
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(): |