Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6368603

Browse files
committed
regrtest: add a summary of the summary, "Result: xxx"
It's sometimes hard to check quickly if tests succeeded, failed or something bad happened. I added a final "Result: xxx" line which summarizes all outputs into a single line, written at the end (it should always be the last line of the output).
1 parent c5a01f8 commit 6368603

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

Lib/test/libregrtest/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,14 @@ def finalize(self):
431431
duration = time.monotonic() - self.start_time
432432
print("Total duration: %s" % format_duration(duration))
433433

434+
if self.bad:
435+
result = "FAILURE"
436+
elif self.interrupted:
437+
result = "INTERRUPTED"
438+
else:
439+
result = "SUCCESS"
440+
print("Result: %s" % result)
441+
434442
if self.ns.runleaks:
435443
os.system("leaks %d" % os.getpid())
436444

Lib/test/test_regrtest.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def parse_executed_tests(self, output):
349349
return list(match.group(1) for match in parser)
350350

351351
def check_executed_tests(self, output, tests, skipped=(), failed=(),
352-
omitted=(), randomize=False):
352+
omitted=(), randomize=False, interrupted=False):
353353
if isinstance(tests, str):
354354
tests = [tests]
355355
if isinstance(skipped, str):
@@ -398,6 +398,17 @@ def list_regex(line_format, tests):
398398
regex = 'All %s' % regex
399399
self.check_line(output, regex)
400400

401+
if interrupted:
402+
self.check_line(output, 'Test suite interrupted by signal SIGINT.')
403+
404+
if nfailed:
405+
result = 'FAILURE'
406+
elif interrupted:
407+
result = 'INTERRUPTED'
408+
else:
409+
result = 'SUCCESS'
410+
self.check_line(output, 'Result: %s' % result)
411+
401412
def parse_random_seed(self, output):
402413
match = self.regex_search(r'Using random seed ([0-9]+)', output)
403414
randseed = int(match.group(1))
@@ -658,7 +669,8 @@ def test_interrupted(self):
658669
code = TEST_INTERRUPTED
659670
test = self.create_test('sigint', code=code)
660671
output = self.run_tests(test, exitcode=1)
661-
self.check_executed_tests(output, test, omitted=test)
672+
self.check_executed_tests(output, test, omitted=test,
673+
interrupted=True)
662674

663675
def test_slowest(self):
664676
# test --slowest
@@ -681,10 +693,11 @@ def test_slow_interrupted(self):
681693
else:
682694
args = ("--slowest", test)
683695
output = self.run_tests(*args, exitcode=1)
684-
self.check_executed_tests(output, test, omitted=test)
696+
self.check_executed_tests(output, test,
697+
omitted=test, interrupted=True)
698+
685699
regex = ('10 slowest tests:\n')
686700
self.check_line(output, regex)
687-
self.check_line(output, 'Test suite interrupted by signal SIGINT.')
688701

689702
def test_coverage(self):
690703
# test --coverage

0 commit comments

Comments
 (0)