Skip to content

Commit 939ef4e

Browse files
committed
Copy the whole graalvm dir for jacoco
1 parent c77359e commit 939ef4e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -519,18 +519,21 @@ def is_included(path):
519519
if agent_args:
520520
# We need to make sure the arguments get passed to subprocesses, so we create a temporary launcher
521521
# 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()
525529
assert re.match(r'^#!.*bash', lines[0]), "jacoco needs a bash launcher"
526530
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)
530533
# jacoco only dumps the data on exit, and when we run all our unittests
531534
# at once it generates so much data we run out of heap space
532535
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)
534537
else:
535538
args += testfiles
536539
mx.logv(" ".join([python_binary] + args))

0 commit comments

Comments
 (0)