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).
This commit is contained in:
Victor Stinner 2016-08-17 16:12:16 +02:00
parent c5a01f8551
commit 636860354e
2 changed files with 25 additions and 4 deletions

View File

@ -431,6 +431,14 @@ class Regrtest:
duration = time.monotonic() - self.start_time duration = time.monotonic() - self.start_time
print("Total duration: %s" % format_duration(duration)) print("Total duration: %s" % format_duration(duration))
if self.bad:
result = "FAILURE"
elif self.interrupted:
result = "INTERRUPTED"
else:
result = "SUCCESS"
print("Result: %s" % result)
if self.ns.runleaks: if self.ns.runleaks:
os.system("leaks %d" % os.getpid()) os.system("leaks %d" % os.getpid())

View File

@ -349,7 +349,7 @@ class BaseTestCase(unittest.TestCase):
return list(match.group(1) for match in parser) return list(match.group(1) for match in parser)
def check_executed_tests(self, output, tests, skipped=(), failed=(), def check_executed_tests(self, output, tests, skipped=(), failed=(),
omitted=(), randomize=False): omitted=(), randomize=False, interrupted=False):
if isinstance(tests, str): if isinstance(tests, str):
tests = [tests] tests = [tests]
if isinstance(skipped, str): if isinstance(skipped, str):
@ -398,6 +398,17 @@ class BaseTestCase(unittest.TestCase):
regex = 'All %s' % regex regex = 'All %s' % regex
self.check_line(output, regex) self.check_line(output, regex)
if interrupted:
self.check_line(output, 'Test suite interrupted by signal SIGINT.')
if nfailed:
result = 'FAILURE'
elif interrupted:
result = 'INTERRUPTED'
else:
result = 'SUCCESS'
self.check_line(output, 'Result: %s' % result)
def parse_random_seed(self, output): def parse_random_seed(self, output):
match = self.regex_search(r'Using random seed ([0-9]+)', output) match = self.regex_search(r'Using random seed ([0-9]+)', output)
randseed = int(match.group(1)) randseed = int(match.group(1))
@ -658,7 +669,8 @@ class ArgsTestCase(BaseTestCase):
code = TEST_INTERRUPTED code = TEST_INTERRUPTED
test = self.create_test('sigint', code=code) test = self.create_test('sigint', code=code)
output = self.run_tests(test, exitcode=1) output = self.run_tests(test, exitcode=1)
self.check_executed_tests(output, test, omitted=test) self.check_executed_tests(output, test, omitted=test,
interrupted=True)
def test_slowest(self): def test_slowest(self):
# test --slowest # test --slowest
@ -681,10 +693,11 @@ class ArgsTestCase(BaseTestCase):
else: else:
args = ("--slowest", test) args = ("--slowest", test)
output = self.run_tests(*args, exitcode=1) output = self.run_tests(*args, exitcode=1)
self.check_executed_tests(output, test, omitted=test) self.check_executed_tests(output, test,
omitted=test, interrupted=True)
regex = ('10 slowest tests:\n') regex = ('10 slowest tests:\n')
self.check_line(output, regex) self.check_line(output, regex)
self.check_line(output, 'Test suite interrupted by signal SIGINT.')
def test_coverage(self): def test_coverage(self):
# test --coverage # test --coverage