|
33 | 33 | import platform
|
34 | 34 | import re
|
35 | 35 | import shutil
|
| 36 | +import shlex |
36 | 37 | import sys
|
37 | 38 |
|
38 | 39 | PY3 = sys.version_info[0] == 3 # compatibility between Python versions
|
@@ -514,19 +515,22 @@ def is_included(path):
|
514 | 515 |
|
515 | 516 | args += [_graalpytest_driver(), "-v"]
|
516 | 517 |
|
517 |
| - agent_args = " ".join(mx_gate.get_jacoco_agent_args() or []) |
| 518 | + agent_args = mx_gate.get_jacoco_agent_args() |
518 | 519 | if agent_args:
|
519 |
| - # if we leave the excludes, the string is too long and it will be ignored by |
520 |
| - # the JVM, which ignores JAVA_TOOL_OPTIONS long than 1024 chars silently on JDK8 |
521 |
| - agent_args = re.sub("excludes=[^,]+,", "", agent_args) |
522 |
| - # we know these can be excluded |
523 |
| - agent_args += ",excludes=*NodeGen*:*LibraryGen*:*BuiltinsFactory*" |
524 |
| - assert len(agent_args) < 1024 |
| 520 | + # We need to make sure the arguments get passed to subprocesses, so we create a temporary launcher |
| 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() |
| 525 | + assert re.match(r'^#!.*bash', lines[0]), "jacoco needs a bash launcher" |
| 526 | + lines.insert(-1, f'jvm_args+=({shlex.join(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) |
525 | 530 | # jacoco only dumps the data on exit, and when we run all our unittests
|
526 | 531 | # at once it generates so much data we run out of heap space
|
527 |
| - env['JAVA_TOOL_OPTIONS'] = agent_args |
528 | 532 | for testfile in testfiles:
|
529 |
| - mx.run([python_binary] + args + [testfile], nonZeroIsFatal=True, env=env) |
| 533 | + mx.run([new_launcher_path] + args + [testfile], nonZeroIsFatal=True, env=env) |
530 | 534 | else:
|
531 | 535 | args += testfiles
|
532 | 536 | mx.logv(" ".join([python_binary] + args))
|
|
0 commit comments