@@ -519,18 +519,21 @@ def is_included(path):
519
519
if agent_args :
520
520
# We need to make sure the arguments get passed to subprocesses, so we create a temporary launcher
521
521
# with the arguments
522
- new_launcher_path = os .path .join (os .path .dirname (os .path .realpath (python_binary )), 'graalpython-jacoco' )
523
- with open (python_binary , 'r' , encoding = 'ascii' , errors = 'ignore' ) as old_launcher :
524
- lines = old_launcher .readlines ()
522
+ basedir = os .path .realpath (os .path .join (os .path .dirname (python_binary ), '..' ))
523
+ jacoco_basedir = f"{ basedir } -jacoco"
524
+ shutil .rmtree (jacoco_basedir , ignore_errors = True )
525
+ shutil .copytree (basedir , jacoco_basedir , symlinks = True )
526
+ launcher_path = os .path .join (jacoco_basedir , 'bin' , 'graalpython' )
527
+ with open (launcher_path , 'r' , encoding = 'ascii' , errors = 'ignore' ) as launcher :
528
+ lines = launcher .readlines ()
525
529
assert re .match (r'^#!.*bash' , lines [0 ]), "jacoco needs a bash launcher"
526
530
lines .insert (- 1 , f'jvm_args+=({ agent_args } )\n ' )
527
- with open (new_launcher_path , 'w' ) as new_launcher :
528
- new_launcher .writelines (lines )
529
- os .chmod (new_launcher_path , 0o755 )
531
+ with open (launcher_path , 'w' ) as launcher :
532
+ launcher .writelines (lines )
530
533
# jacoco only dumps the data on exit, and when we run all our unittests
531
534
# at once it generates so much data we run out of heap space
532
535
for testfile in testfiles :
533
- mx .run ([new_launcher_path ] + args + [testfile ], nonZeroIsFatal = True , env = env )
536
+ mx .run ([launcher_path ] + args + [testfile ], nonZeroIsFatal = True , env = env )
534
537
else :
535
538
args += testfiles
536
539
mx .logv (" " .join ([python_binary ] + args ))
0 commit comments