@@ -606,20 +606,22 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Tr
606
606
# We need to make sure the arguments get passed to subprocesses, so we create a temporary launcher
607
607
# with the arguments
608
608
basedir = os .path .realpath (os .path .join (os .path .dirname (python_binary ), '..' ))
609
- jacoco_basedir = "%s-jacoco" % basedir
610
- shutil .rmtree (jacoco_basedir , ignore_errors = True )
611
- shutil .copytree (basedir , jacoco_basedir , symlinks = True )
612
- launcher_path = os .path .join (jacoco_basedir , 'bin' , 'graalpython' )
613
- with open (launcher_path , 'r' , encoding = 'ascii' , errors = 'ignore' ) as launcher :
614
- lines = launcher .readlines ()
615
- assert re .match (r'^#!.*bash' , lines [0 ]), "jacoco needs a bash launcher"
616
- lines .insert (- 1 , 'jvm_args+=(%s)\n ' % agent_args )
617
- with open (launcher_path , 'w' ) as launcher :
618
- launcher .writelines (lines )
619
- # jacoco only dumps the data on exit, and when we run all our unittests
620
- # at once it generates so much data we run out of heap space
621
- for testfile in testfiles :
622
- mx .run ([launcher_path ] + args + [testfile ], nonZeroIsFatal = True , env = env )
609
+ launcher_path = os .path .join (basedir , 'bin' , 'graalpython' )
610
+ launcher_path_bak = launcher_path + ".bak"
611
+ shutil .copy (launcher_path , launcher_path_bak )
612
+ try :
613
+ with open (launcher_path , 'r' , encoding = 'ascii' , errors = 'ignore' ) as launcher :
614
+ lines = launcher .readlines ()
615
+ assert re .match (r'^#!.*bash' , lines [0 ]), "jacoco needs a bash launcher"
616
+ lines .insert (- 1 , 'jvm_args+=(%s)\n ' % agent_args )
617
+ with open (launcher_path , 'w' ) as launcher :
618
+ launcher .writelines (lines )
619
+ # jacoco only dumps the data on exit, and when we run all our unittests
620
+ # at once it generates so much data we run out of heap space
621
+ for testfile in testfiles :
622
+ mx .run ([launcher_path ] + args + [testfile ], nonZeroIsFatal = True , env = env )
623
+ finally :
624
+ shutil .move (launcher_path_bak , launcher_path )
623
625
else :
624
626
args += testfiles
625
627
mx .logv (" " .join ([python_binary ] + args ))
0 commit comments