aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/_distutils/tests/test_msvccompiler.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-08-02 09:56:57 -0400
committerJason R. Coombs <jaraco@jaraco.com>2020-08-02 09:56:57 -0400
commitc2fcb01de1306ec7171bd4cd6c2db20be6011cbd (patch)
treea04e1838faa5085204f453e4153fa697b69a76c7 /setuptools/_distutils/tests/test_msvccompiler.py
parent5578b4466d236ba3516a9df726e0c08a2eea3f06 (diff)
parent51b75e95de717a7d37bd1915a104a9e830fe5651 (diff)
downloadexternal_python_setuptools-c2fcb01de1306ec7171bd4cd6c2db20be6011cbd.tar.gz
external_python_setuptools-c2fcb01de1306ec7171bd4cd6c2db20be6011cbd.tar.bz2
external_python_setuptools-c2fcb01de1306ec7171bd4cd6c2db20be6011cbd.zip
Merge branch 'clean' of https://github.com/pypa/distutils into master
Diffstat (limited to 'setuptools/_distutils/tests/test_msvccompiler.py')
-rw-r--r--setuptools/_distutils/tests/test_msvccompiler.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/setuptools/_distutils/tests/test_msvccompiler.py b/setuptools/_distutils/tests/test_msvccompiler.py
index b518d6a7..88d912b1 100644
--- a/setuptools/_distutils/tests/test_msvccompiler.py
+++ b/setuptools/_distutils/tests/test_msvccompiler.py
@@ -2,6 +2,7 @@
import sys
import unittest
import os
+import threading
from distutils.errors import DistutilsPlatformError
from distutils.tests import support
@@ -74,6 +75,42 @@ class msvccompilerTestCase(support.TempdirManager,
else:
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):
+ """
+ Concurrent calls to spawn should have consistent results.
+ """
+ import distutils._msvccompiler as _msvccompiler
+ compiler = _msvccompiler.MSVCCompiler()
+ compiler._paths = "expected"
+ inner_cmd = 'import os; assert os.environ["PATH"] == "expected"'
+ command = ['python', '-c', inner_cmd]
+
+ threads = [
+ 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():
return unittest.makeSuite(msvccompilerTestCase)