Skip to content

Commit 39bc77a

Browse files
committed
Fix tracking Truffle coverage for lib-graalpython
1 parent 2bb8ca8 commit 39bc77a

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import sys
3939
import time
4040
from functools import wraps
41+
from textwrap import dedent
4142

4243
import mx_urlrewrites
4344

@@ -2308,18 +2309,22 @@ def python_coverage(args):
23082309
# {"args": ["--llvm.managed"]},
23092310
]
23102311

2312+
common_coverage_args = [
2313+
"--experimental-options",
2314+
"--llvm.lazyParsing=false",
2315+
"--python.DisableFrozenModules", # To have proper source information about lib-graalpython
2316+
"--coverage",
2317+
"--coverage.TrackInternal",
2318+
f"--coverage.FilterFile={file_filter}",
2319+
"--coverage.Output=lcov",
2320+
]
23112321
for kwds in variants:
23122322
variant_str = re.sub(r"[^a-zA-Z]", "_", str(kwds))
23132323
outfile = os.path.join(SUITE.dir, "coverage_%s_$UUID$.lcov" % variant_str)
23142324
if os.path.exists(outfile):
23152325
os.unlink(outfile)
23162326
extra_args = [
2317-
"--experimental-options",
2318-
"--llvm.lazyParsing=false",
2319-
"--coverage",
2320-
"--coverage.TrackInternal",
2321-
f"--coverage.FilterFile={file_filter}",
2322-
"--coverage.Output=lcov",
2327+
*common_coverage_args,
23232328
f"--coverage.OutputFile={outfile}",
23242329
]
23252330
env['GRAAL_PYTHON_ARGS'] = " ".join(extra_args)
@@ -2337,23 +2342,23 @@ def python_coverage(args):
23372342
# coverage. this is to ensure all sources actuall show up - otherwise,
23382343
# only loaded sources will be part of the coverage
23392344
with tempfile.NamedTemporaryFile(mode="w", suffix='.py') as f:
2340-
f.write("""
2341-
import os
2342-
2343-
for dirpath, dirnames, filenames in os.walk('{0}'):
2344-
if "test" in dirnames:
2345-
dirnames.remove("test")
2346-
if "tests" in dirnames:
2347-
dirnames.remove("tests")
2348-
for filename in filenames:
2349-
if filename.endswith(".py"):
2350-
fullname = os.path.join(dirpath, filename)
2351-
with open(fullname, 'rb') as f:
2352-
try:
2353-
compile(f.read(), fullname, 'exec')
2354-
except BaseException as e:
2355-
print('Could not compile', fullname, e)
2356-
""".format(os.path.join(SUITE.dir, "graalpython", "lib-python")))
2345+
f.write(dedent(f"""
2346+
import os
2347+
2348+
for dirpath, dirnames, filenames in os.walk({os.path.join(SUITE.dir, "graalpython", "lib-graalpython")!r}):
2349+
if "test" in dirnames:
2350+
dirnames.remove("test")
2351+
if "tests" in dirnames:
2352+
dirnames.remove("tests")
2353+
for filename in filenames:
2354+
if filename.endswith(".py"):
2355+
fullname = os.path.join(dirpath, filename)
2356+
with open(fullname, 'rb') as f:
2357+
try:
2358+
compile(f.read(), fullname, 'exec')
2359+
except BaseException as e:
2360+
print('Could not compile', fullname, e)
2361+
"""))
23572362
f.flush()
23582363
lcov_file = 'zero.lcov'
23592364
try:
@@ -2366,14 +2371,9 @@ def python_coverage(args):
23662371
mx.run([
23672372
executable,
23682373
"-S",
2369-
"--experimental-options",
2370-
"--llvm.lazyParsing=false",
2374+
*common_coverage_args,
23712375
"--python.PosixModuleBackend=java",
2372-
"--coverage",
2373-
"--coverage.TrackInternal",
2374-
f"--coverage.FilterFile={file_filter}",
2375-
"--coverage.Output=lcov",
2376-
"--coverage.OutputFile=" + lcov_file,
2376+
f"--coverage.OutputFile={lcov_file}",
23772377
f.name
23782378
], env=None)
23792379

0 commit comments

Comments
 (0)