@@ -1238,7 +1238,7 @@ def python_coverage(args):
1238
1238
if args .truffle :
1239
1239
executable = python_gvm ()
1240
1240
variants = [
1241
- {},
1241
+ {"args" : [] },
1242
1242
{"args" : ["--python.EmulateJython" ], "paths" : ["test_interop.py" ]},
1243
1243
# {"args": ["--llvm.managed"]},
1244
1244
{
@@ -1252,9 +1252,9 @@ def python_coverage(args):
1252
1252
os .unlink (outputlcov )
1253
1253
cmdargs = ["/usr/bin/env" , "lcov" , "-o" , outputlcov ]
1254
1254
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 ))
1256
1256
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 ))
1258
1258
if os .path .exists (outfile ):
1259
1259
os .unlink (outfile )
1260
1260
extra_args = [
@@ -1264,14 +1264,25 @@ def python_coverage(args):
1264
1264
"--coverage.Output=lcov" ,
1265
1265
"--coverage.OutputFile=%s" % outfile ,
1266
1266
]
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
+
1275
1286
mx .run (cmdargs )
1276
1287
primary = mx .primary_suite ()
1277
1288
info = primary .vc .parent_info (primary .dir )
0 commit comments