38
38
import sys
39
39
import time
40
40
from functools import wraps
41
+ from textwrap import dedent
41
42
42
43
import mx_urlrewrites
43
44
@@ -2308,18 +2309,22 @@ def python_coverage(args):
2308
2309
# {"args": ["--llvm.managed"]},
2309
2310
]
2310
2311
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
+ ]
2311
2321
for kwds in variants :
2312
2322
variant_str = re .sub (r"[^a-zA-Z]" , "_" , str (kwds ))
2313
2323
outfile = os .path .join (SUITE .dir , "coverage_%s_$UUID$.lcov" % variant_str )
2314
2324
if os .path .exists (outfile ):
2315
2325
os .unlink (outfile )
2316
2326
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 ,
2323
2328
f"--coverage.OutputFile={ outfile } " ,
2324
2329
]
2325
2330
env ['GRAAL_PYTHON_ARGS' ] = " " .join (extra_args )
@@ -2337,23 +2342,23 @@ def python_coverage(args):
2337
2342
# coverage. this is to ensure all sources actuall show up - otherwise,
2338
2343
# only loaded sources will be part of the coverage
2339
2344
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
+ """ ))
2357
2362
f .flush ()
2358
2363
lcov_file = 'zero.lcov'
2359
2364
try :
@@ -2366,14 +2371,9 @@ def python_coverage(args):
2366
2371
mx .run ([
2367
2372
executable ,
2368
2373
"-S" ,
2369
- "--experimental-options" ,
2370
- "--llvm.lazyParsing=false" ,
2374
+ * common_coverage_args ,
2371
2375
"--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 } " ,
2377
2377
f .name
2378
2378
], env = None )
2379
2379
0 commit comments