@@ -698,7 +698,7 @@ def is_included(path):
698
698
699
699
700
700
def run_python_unittests (python_binary , args = None , paths = None , aot_compatible = False , exclude = None , env = None ,
701
- use_pytest = False , cwd = None , lock = None , out = None , err = None ):
701
+ use_pytest = False , cwd = None , lock = None , out = None , err = None , nonZeroIsFatal = True ):
702
702
if lock :
703
703
lock .acquire ()
704
704
# ensure that the test distribution is up-to-date
@@ -760,13 +760,13 @@ def graalvm_vm_arg(java_arg):
760
760
# at once it generates so much data we run out of heap space
761
761
for testfile in testfiles :
762
762
mx .run ([python_binary , "--jvm" , agent_args ] + args + [testfile ],
763
- nonZeroIsFatal = False , env = env , cwd = cwd , out = out , err = err )
763
+ nonZeroIsFatal = nonZeroIsFatal , env = env , cwd = cwd , out = out , err = err )
764
764
else :
765
765
args += testfiles
766
766
mx .logv (" " .join ([python_binary ] + args ))
767
767
if lock :
768
768
lock .release ()
769
- return mx .run ([python_binary ] + args , nonZeroIsFatal = True , env = env , cwd = cwd , out = out , err = err )
769
+ return mx .run ([python_binary ] + args , nonZeroIsFatal = nonZeroIsFatal , env = env , cwd = cwd , out = out , err = err )
770
770
771
771
772
772
def is_bash_launcher (launcher_path ):
@@ -800,20 +800,21 @@ def run_hpy_unittests(python_binary, args=None, include_native=True):
800
800
threads = []
801
801
lock = threading .RLock ()
802
802
803
- class RaisingThread (threading .Thread ):
803
+ class HPyUnitTestsThread (threading .Thread ):
804
804
def __init__ (self , ** tkwargs ):
805
- capture = mx .LinesOutputCapture ()
806
- tkwargs ["kwargs" ]["out" ] = capture
807
- tkwargs ["kwargs" ]["err" ] = capture
808
805
super ().__init__ (** tkwargs )
809
- self .out = capture
810
- self .exc = None
806
+ self .out = mx . LinesOutputCapture ()
807
+ self .result = None
811
808
812
809
def run (self ):
810
+ # Note: for some reason catching BaseException is not enough to catch mx.abort,
811
+ # so we use nonZeroIsFatal=False instead.
813
812
try :
814
- super ().run ()
815
- except Exception as e : # pylint: disable=broad-except;
816
- self .exc = e
813
+ self .result = run_python_unittests (python_binary , args = args , paths = [_hpy_test_root ()],
814
+ env = tenv , use_pytest = True , lock = lock , nonZeroIsFatal = False ,
815
+ out = self .out , err = self .out )
816
+ except BaseException as e : # pylint: disable=broad-except;
817
+ self .result = e
817
818
818
819
abi_list = ['cpython' , 'universal' ]
819
820
if include_native :
@@ -822,9 +823,7 @@ def run(self):
822
823
for abi in abi_list :
823
824
tenv = env .copy ()
824
825
tenv ["TEST_HPY_ABI" ] = abi
825
- thread = RaisingThread (name = abi , target = run_python_unittests , args = (python_binary , ), kwargs = {
826
- "args" : args , "paths" : [_hpy_test_root ()], "env" : tenv , "use_pytest" : True , "lock" : lock ,
827
- })
826
+ thread = HPyUnitTestsThread (name = abi )
828
827
threads .append (thread )
829
828
thread .start ()
830
829
@@ -835,8 +834,8 @@ def run(self):
835
834
mx .logv ("## Progress (last 5 lines) of thread %r:\n %s\n " % (t .name , os .linesep .join (t .out .lines [- 5 :])))
836
835
alive [i ] = t .is_alive ()
837
836
838
- thread_exceptions = [t .exc for t in threads ]
839
- if any (thread_exceptions ):
837
+ thread_errors = [t .result for t in threads if t . result != 0 ]
838
+ if any (thread_errors ):
840
839
for t in threads :
841
840
mx .log_error ("\n \n ### Output of thread %r: \n \n %s" % (t .name , t .out ))
842
841
mx .abort ("At least one HPy testing thread failed." )
0 commit comments