Skip to content

Commit f250ba5

Browse files
committed
track coverage in subprocesses, too
1 parent 5804b01 commit f250ba5

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ def python_coverage(args):
12381238
if args.truffle:
12391239
executable = python_gvm()
12401240
variants = [
1241-
{},
1241+
{"args": []},
12421242
{"args": ["--python.EmulateJython"], "paths": ["test_interop.py"]},
12431243
# {"args": ["--llvm.managed"]},
12441244
{
@@ -1252,9 +1252,9 @@ def python_coverage(args):
12521252
os.unlink(outputlcov)
12531253
cmdargs = ["/usr/bin/env", "lcov", "-o", outputlcov]
12541254
for kwds in variants:
1255-
variant_str = re.sub(r"[^a-zA-Z]", "_", repr(kwds))
1255+
variant_str = re.sub(r"[^a-zA-Z]", "_", str(kwds))
12561256
for pattern in ["py"]:
1257-
outfile = os.path.join(SUITE.dir, "coverage_%s_%s.lcov" % (variant_str, pattern))
1257+
outfile = os.path.join(SUITE.dir, "coverage_%s_%s_$$.lcov" % (variant_str, pattern))
12581258
if os.path.exists(outfile):
12591259
os.unlink(outfile)
12601260
extra_args = [
@@ -1264,14 +1264,25 @@ def python_coverage(args):
12641264
"--coverage.Output=lcov",
12651265
"--coverage.OutputFile=%s" % outfile,
12661266
]
1267-
kwds["args"] = extra_args + kwds.get("args", [])
1268-
if kwds.pop("tagged", False):
1269-
with set_env(ENABLE_CPYTHON_TAGGED_UNITTESTS="true", ENABLE_THREADED_GRAALPYTEST="true"):
1270-
with _dev_pythonhome_context():
1271-
run_python_unittests(executable, **kwds)
1272-
else:
1273-
run_python_unittests(executable, **kwds)
1274-
cmdargs += ["-a", outfile]
1267+
with set_env(GRAAL_PYTHON_ARGS=" ".join(extra_args)):
1268+
if kwds.pop("tagged", False):
1269+
with set_env(ENABLE_CPYTHON_TAGGED_UNITTESTS="true", ENABLE_THREADED_GRAALPYTEST="true"):
1270+
with _dev_pythonhome_context():
1271+
run_python_unittests(executable, **kwds)
1272+
else:
1273+
run_python_unittests(executable, **kwds)
1274+
1275+
# some code runs in the suite dir, some in the graalvm home. we merge these manually
1276+
local_dir = os.path.join(SUITE.dir, "graalpython")
1277+
graalvm_dir = os.path.join(os.path.dirname(os.path.dirname(executable)), "jre", "languages", "python")
1278+
for f in os.listdir(SUITE.dir):
1279+
if f.endswith(".lcov"):
1280+
with open(f, "r") as lcovfile:
1281+
contents = lcovfile.read()
1282+
with open(f, "w") as lcovfile:
1283+
lcovfile.write(contents.replace(graalvm_dir, local_dir))
1284+
cmdargs += ["-a", f]
1285+
12751286
mx.run(cmdargs)
12761287
primary = mx.primary_suite()
12771288
info = primary.vc.parent_info(primary.dir)

0 commit comments

Comments
 (0)