# FIXME: Re-try after timeout on Windows.
lit_config.warning("Failed to delete temp directory '%s'" % tmp_dir)
-def print_summary(tests, elapsed, opts):
- if not opts.quiet:
- print('\nTesting Time: %.2fs' % elapsed)
- byCode = {}
+def print_summary(tests, elapsed, opts):
+ # Status code, summary label, group label
+ groups = [
+ # Successes
+ (lit.Test.UNSUPPORTED, 'Unsupported Tests ', 'Unsupported'),
+ (lit.Test.PASS, 'Expected Passes ', ''),
+ (lit.Test.FLAKYPASS, 'Passes With Retry ', ''),
+ (lit.Test.XFAIL, 'Expected Failures ', 'Expected Failing'),
+ # Failures
+ (lit.Test.UNRESOLVED, 'Unresolved Tests ', 'Unresolved'),
+ (lit.Test.TIMEOUT, 'Individual Timeouts', 'Timed Out'),
+ (lit.Test.FAIL, 'Unexpected Failures', 'Failing'),
+ (lit.Test.XPASS, 'Unexpected Passes ', 'Unexpected Passing')]
+
+ by_code = {code: [] for (code, _, _) in groups}
for test in tests:
- if test.result.code not in byCode:
- byCode[test.result.code] = []
- byCode[test.result.code].append(test)
-
- # Print each test in any of the failing groups.
- for title,code in (('Unexpected Passing Tests', lit.Test.XPASS),
- ('Failing Tests', lit.Test.FAIL),
- ('Unresolved Tests', lit.Test.UNRESOLVED),
- ('Unsupported Tests', lit.Test.UNSUPPORTED),
- ('Expected Failing Tests', lit.Test.XFAIL),
- ('Timed Out Tests', lit.Test.TIMEOUT)):
- if (lit.Test.XFAIL == code and not opts.show_xfail) or \
- (lit.Test.UNSUPPORTED == code and not opts.show_unsupported) or \
- (lit.Test.UNRESOLVED == code and (opts.max_failures is not None)):
- continue
- elts = byCode.get(code)
- if not elts:
- continue
- print('*'*20)
- print('%s (%d):' % (title, len(elts)))
- for test in elts:
- print(' %s' % test.getFullName())
- sys.stdout.write('\n')
+ by_code[test.result.code].append(test)
+
+ for (code, _, group_label) in groups:
+ print_group(code, group_label, by_code[code], opts)
if opts.timeTests and tests:
- # Order by time.
- test_times = [(test.getFullName(), test.result.elapsed)
- for test in tests]
+ test_times = [(t.getFullName(), t.result.elapsed) for t in tests]
lit.util.printHistogram(test_times, title='Tests')
- for name,code in (('Expected Passes ', lit.Test.PASS),
- ('Passes With Retry ', lit.Test.FLAKYPASS),
- ('Expected Failures ', lit.Test.XFAIL),
- ('Unsupported Tests ', lit.Test.UNSUPPORTED),
- ('Unresolved Tests ', lit.Test.UNRESOLVED),
- ('Unexpected Passes ', lit.Test.XPASS),
- ('Unexpected Failures', lit.Test.FAIL),
- ('Individual Timeouts', lit.Test.TIMEOUT)):
- if opts.quiet and not code.isFailure:
- continue
- N = len(byCode.get(code,[]))
- if N:
- print(' %s: %d' % (name,N))
+ if not opts.quiet:
+ print('\nTesting Time: %.2fs' % elapsed)
+ for (code, summary_label, _) in groups:
+ print_group_summary(code, summary_label, by_code[code], opts.quiet)
+
+
+def print_group(code, label, tests, opts):
+ if not tests:
+ return
+ if code == lit.Test.PASS:
+ return
+ if (lit.Test.XFAIL == code and not opts.show_xfail) or \
+ (lit.Test.UNSUPPORTED == code and not opts.show_unsupported) or \
+ (lit.Test.UNRESOLVED == code and (opts.max_failures is not None)):
+ return
+ print('*' * 20)
+ print('%s Tests (%d):' % (label, len(tests)))
+ for test in tests:
+ print(' %s' % test.getFullName())
+ sys.stdout.write('\n')
+
+
+def print_group_summary(code, label, tests, quiet):
+ count = len(tests)
+ if count and (code.isFailure or not quiet):
+ print(' %s: %d' % (label, count))
+
def write_test_results(tests, lit_config, elapsed, output_path):
# TODO(yln): audit: unexecuted tests