Skip to content

Commit 617ea12

Browse files
committed
Fix invocation of tests for truffle coverage
1 parent 6d2a547 commit 617ea12

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,24 @@ def is_included(path):
537537
return mx.run([python_binary] + args, nonZeroIsFatal=True, env=env)
538538

539539

540+
def run_tagged_unittests(python_binary, env=None):
541+
if env is None:
542+
env = os.environ
543+
env = env.copy()
544+
env.update(
545+
ENABLE_CPYTHON_TAGGED_UNITTESTS="true",
546+
ENABLE_THREADED_GRAALPYTEST="true",
547+
PYTHONPATH=os.path.join(_dev_pythonhome(), 'lib-python/3'),
548+
)
549+
run_python_unittests(
550+
python_binary,
551+
args=["-v",
552+
"--python.WithThread=true"],
553+
paths=["test_tagged_unittests.py"],
554+
env=env,
555+
)
556+
557+
540558
def graalpython_gate_runner(args, tasks):
541559
# JUnit tests
542560
with Task('GraalPython JUnit', tasks, tags=[GraalPythonTags.junit]) as task:
@@ -568,19 +586,7 @@ def graalpython_gate_runner(args, tasks):
568586

569587
with Task('GraalPython Python tests', tasks, tags=[GraalPythonTags.tagged]) as task:
570588
if task:
571-
env = os.environ.copy()
572-
env.update(
573-
ENABLE_CPYTHON_TAGGED_UNITTESTS="true",
574-
ENABLE_THREADED_GRAALPYTEST="true",
575-
PYTHONPATH=os.path.join(_dev_pythonhome(), 'lib-python/3'),
576-
)
577-
run_python_unittests(
578-
python_gvm(),
579-
args=["-v",
580-
"--python.WithThread=true"],
581-
paths=["test_tagged_unittests.py"],
582-
env=env,
583-
)
589+
run_tagged_unittests(python_gvm())
584590

585591
# Unittests on SVM
586592
with Task('GraalPython tests on SVM', tasks, tags=[GraalPythonTags.svmunit]) as task:
@@ -1424,11 +1430,7 @@ def python_coverage(args):
14241430
{"args": []},
14251431
{"args": ["--python.EmulateJython"], "paths": ["test_interop.py"]},
14261432
# {"args": ["--llvm.managed"]},
1427-
{
1428-
"args": ["-v", "--python.WithThread=true"],
1429-
"paths": ["test_tagged_unittests.py"],
1430-
"tagged": True
1431-
},
1433+
{"tagged": True},
14321434
]
14331435
outputlcov = "coverage.lcov"
14341436
if os.path.exists(outputlcov):
@@ -1442,20 +1444,21 @@ def python_coverage(args):
14421444
if os.path.exists(outfile):
14431445
os.unlink(outfile)
14441446
extra_args = [
1447+
"--experimental-options",
14451448
"--coverage",
14461449
"--coverage.TrackInternal",
1447-
"--coverage.FilterFile=%s/*.%s" % (prefix, pattern),
1450+
"--coverage.FilterFile=%s/lib-*python/*.%s" % (prefix, pattern),
14481451
"--coverage.Output=lcov",
14491452
"--coverage.OutputFile=%s" % outfile,
14501453
]
1451-
with set_env(GRAAL_PYTHON_ARGS=" ".join(extra_args)):
1452-
with _dev_pythonhome_context(): # run all our tests in the dev-home, so that lcov has consistent paths
1453-
kwds["args"].append("--python.CAPI=" + _get_capi_home())
1454-
if kwds.pop("tagged", False):
1455-
with set_env(ENABLE_CPYTHON_TAGGED_UNITTESTS="true", ENABLE_THREADED_GRAALPYTEST="true"):
1456-
run_python_unittests(executable, **kwds)
1457-
else:
1458-
run_python_unittests(executable, **kwds)
1454+
env = os.environ.copy()
1455+
env['GRAAL_PYTHON_ARGS'] = " ".join(extra_args)
1456+
# run all our tests in the dev-home, so that lcov has consistent paths
1457+
env['PYTHONPATH'] = os.path.join(_dev_pythonhome(), 'lib-python/3')
1458+
if kwds.pop("tagged", False):
1459+
run_tagged_unittests(executable, env=env)
1460+
else:
1461+
run_python_unittests(executable, env=env, **kwds)
14591462

14601463
# generate a synthetic lcov file that includes all sources with 0
14611464
# coverage. this is to ensure all sources actuall show up - otherwise,

0 commit comments

Comments
 (0)