@@ -43,6 +43,13 @@ def parse_cmdline_args():
43
43
'it. If this option is not provided, and the build directory is not '
44
44
'empty, an error will be raised.'
45
45
)
46
+ ap .add_argument (
47
+ '-e' ,
48
+ '--existing' ,
49
+ default = False ,
50
+ action = 'store_true' ,
51
+ help = 'Don\' t run the tests. Only process existing test results.'
52
+ )
46
53
ap .add_argument (
47
54
'-i' ,
48
55
'--inplace' ,
@@ -147,7 +154,6 @@ def parse_disabled_file(args, filename):
147
154
re_comment = re .compile ('^[ ]*#.*$' )
148
155
re_close = re .compile ('^[ ]*[)][ ]*$' )
149
156
150
- d = os .path .dirname (filename )
151
157
record = False
152
158
tests = []
153
159
with open (filename ) as f :
@@ -323,10 +329,60 @@ def build_and_run_tests(args, build_root, config):
323
329
)
324
330
exit (1 )
325
331
332
+ # Parse the test results. The result is a map whose key is the absolute path
333
+ # to the main test file and the value is a boolean indicating whether the test
334
+ # passed or failed. build_root is the root of the build directory. config must
335
+ # be either 'default' or 'all'.
336
+ # { str : * }, os.path, str -> { os.path : bool }
337
+ def parse_test_results (args , build_root , config ):
338
+ if args .verbose or args .dry_run :
339
+ print (f'Parsing test results for ${ config } configuration' )
340
+ if args .dry_run :
341
+ return {}
342
+
343
+ j = None
344
+ with open (os .path .join (build_root , config + '.json' )) as f :
345
+ j = json .load (f )
346
+
347
+ results = {}
348
+ for tj in j ['tests' ]:
349
+ name = tj ['name' ].split ('::' )[1 ].strip ()
350
+ elems = name .split ('/' )
351
+ dirs = elems [:- 1 ]
352
+ filename = elems [- 1 ]
353
+
354
+ filename = filename .replace ('gfortran-regression-' , '' )
355
+ filename = filename .replace ('gfortran-torture-' , '' )
356
+ if dirs [2 ] == 'regression' :
357
+ filename = filename .replace ('compile-regression' , '' )
358
+ filename = filename .replace ('execute-regression' , '' )
359
+ elif dirs [2 ] == 'torture' :
360
+ filename = filename .replace ('compile-torture' , '' )
361
+ filename = filename .replace ('execute-torture' , '' )
362
+ for d in dirs [3 :]:
363
+ filename = filename .replace ('__' + d , '' , 1 )
364
+ filename = filename [2 :- 5 ]
365
+
366
+ base , _ , ext = filename .rpartition ('_' )
367
+ fname = '.' .join ([base , ext ])
368
+ # The tests in regression/gomp/appendix-a contain .'s in the name which
369
+ # are replaced with _'s in the test name.
370
+ if dirs [- 1 ] == 'appendix-a' :
371
+ fname = fname .replace ('_' , '.' )
372
+
373
+ f = os .path .join (args .source , * dirs , fname )
374
+ if os .path .exists (f ):
375
+ results [fname ] = tj ['code' ] == 'PASS'
376
+
377
+ return results
378
+
326
379
# Compare the test results and get the list of tests to be enabled. The result
327
- # will be a list of paths to tests that should be enabled.
328
- # os.path -> [os.path]
329
- def get_tests_to_be_enabled (build_dir ):
380
+ # will be a list of paths to tests that should be enabled. build_root is the
381
+ # root of the build directory.
382
+ # { str : * }, os.path -> [os.path]
383
+ def get_tests_to_be_enabled (args , build_root ):
384
+ results_def = parse_test_results (args , build_root , 'default' )
385
+ results_all = parse_test_results (args , build_root , 'all' )
330
386
# TODO: Implement this.
331
387
return []
332
388
@@ -349,22 +405,19 @@ def main():
349
405
for test in parse_disabled_file (args , filename ):
350
406
check_disabled [d ].append (os .path .join (d , test ))
351
407
352
- print (len (check_disabled ))
353
- for d , tests in check_disabled .items ():
354
- print (d , len (tests ))
355
- exit (0 )
356
408
build_dir = setup_build_dir (args )
357
409
358
- build_and_run_tests (args , build_dir , 'default' )
359
- build_and_run_tests (args , build_dir , 'all' )
410
+ if not args .existing :
411
+ build_and_run_tests (args , build_dir , 'default' )
412
+ build_and_run_tests (args , build_dir , 'all' )
360
413
361
414
enabled = get_tests_to_be_enabled (build_dir )
362
415
if args .verbose or args .dry_run :
363
416
print (f'Enabling { len (enabled )} tests' )
364
417
for test in enabled :
365
418
print (' ' , test )
366
419
if not args .dry_run :
367
- update_disabled_lists (args , enabled_tests )
420
+ update_disabled_lists (args , enabled )
368
421
369
422
# Cleanup, if necessary.
370
423
teardown_build_dir (args , build_dir )
0 commit comments