aboutsummaryrefslogtreecommitdiffstats
path: root/distutils/tests/test_msvccompiler.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-08-02 09:32:51 -0400
committerJason R. Coombs <jaraco@jaraco.com>2020-08-02 09:32:51 -0400
commit7f233974b0e3dc3692c820a2c8c3439c4d15fc70 (patch)
tree0698717db710b0c9ec12fbdd651a4d2a70a4c962 /distutils/tests/test_msvccompiler.py
parent1215561b96389403cbbd55889e54b67db873ddcb (diff)
downloadexternal_python_setuptools-7f233974b0e3dc3692c820a2c8c3439c4d15fc70.tar.gz
external_python_setuptools-7f233974b0e3dc3692c820a2c8c3439c4d15fc70.tar.bz2
external_python_setuptools-7f233974b0e3dc3692c820a2c8c3439c4d15fc70.zip
Add a unit test for testing spawn. Ref pypa/distutils#5.
Diffstat (limited to 'distutils/tests/test_msvccompiler.py')
-rw-r--r--distutils/tests/test_msvccompiler.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/distutils/tests/test_msvccompiler.py b/distutils/tests/test_msvccompiler.py
index b518d6a7..f4bb5162 100644
--- a/distutils/tests/test_msvccompiler.py
+++ b/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,28 @@ class msvccompilerTestCase(support.TempdirManager,
else:
raise unittest.SkipTest("VS 2015 is not installed")
+
+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 = [
+ threading.Thread(target=compiler.spawn, args=[command])
+ for n in range(100)
+ ]
+ for thread in threads:
+ thread.start()
+ for thread in threads:
+ thread.join()
+
+
def test_suite():
return unittest.makeSuite(msvccompilerTestCase)