Skip to content

Commit 2e1c64a

Browse files
committed
Fix coverage gate
we copied the tree of the graalvm including the already generated pyc files. unfortunately, that meant we were loading pyc files that had their filename set to the original path, which conflicts with the target path we copied to
1 parent 87b5014 commit 2e1c64a

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -606,20 +606,22 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Tr
606606
# We need to make sure the arguments get passed to subprocesses, so we create a temporary launcher
607607
# with the arguments
608608
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)
623625
else:
624626
args += testfiles
625627
mx.logv(" ".join([python_binary] + args))

0 commit comments

Comments
 (0)