@@ -674,7 +674,9 @@ def is_included(path):
674
674
return testfiles
675
675
676
676
677
- def run_python_unittests (python_binary , args = None , paths = None , aot_compatible = False , exclude = None , env = None , use_pytest = False , cwd = None ):
677
+ def run_python_unittests (python_binary , args = None , paths = None , aot_compatible = False , exclude = None , env = None , use_pytest = False , cwd = None , lock = None ):
678
+ if lock :
679
+ lock .acquire ()
678
680
# ensure that the test distribution is up-to-date
679
681
mx .command_function ("build" )(["--dep" , "com.oracle.graal.python.test" ])
680
682
@@ -737,6 +739,8 @@ def graalvm_vm_arg(java_arg):
737
739
else :
738
740
args += testfiles
739
741
mx .logv (" " .join ([python_binary ] + args ))
742
+ if lock :
743
+ lock .release ()
740
744
return mx .run ([python_binary ] + args , nonZeroIsFatal = True , env = env , cwd = cwd )
741
745
742
746
@@ -766,8 +770,31 @@ def run_hpy_unittests(python_binary, args=None):
766
770
mx .log ("LLVM Toolchain (vanilla): {!s}" .format (env ["LLVM_TOOLCHAIN_VANILLA" ]))
767
771
mx .log ("Ensure 'setuptools' is installed" )
768
772
mx .run ([python_binary ] + args + ["-m" , "ginstall" , "install" , "--user" , "pytest" ], nonZeroIsFatal = True , env = env )
769
-
770
- return run_python_unittests (python_binary , args = args , paths = [_hpy_test_root ()], env = env , use_pytest = True )
773
+ # parallelize
774
+ import threading
775
+ threads = []
776
+ lock = threading .RLock ()
777
+
778
+ class RaisingThread (threading .Thread ):
779
+ def run (self ):
780
+ self .exc = None
781
+ try :
782
+ super ().run ()
783
+ except Exception as e :
784
+ self .exc = e
785
+
786
+ for abi in ['cpython' , 'universal' , 'debug' , 'nfi' ]:
787
+ env ["TEST_HPY_ABI" ] = abi
788
+ threads .append (RaisingThread (target = run_python_unittests , args = (python_binary , ), kwargs = {
789
+ "args" : args , "paths" : [_hpy_test_root ()], "env" : env .copy (), "use_pytest" : True , "lock" : lock ,
790
+ }))
791
+ threads [- 1 ].start ()
792
+ retval = 0
793
+ for t in threads :
794
+ t .join ()
795
+ for t in threads :
796
+ if t .exc :
797
+ raise t .exc
771
798
772
799
773
800
def run_tagged_unittests (python_binary , env = None , cwd = None ):
0 commit comments