From 636860354ee7be4b7bf55dddb0cbb129c989b681 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 17 Aug 2016 16:12:16 +0200 Subject: 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). --- Lib/test/libregrtest/main.py | 8 ++++++++ Lib/test/test_regrtest.py | 21 +++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py index 0723c43..78c52bd 100644 --- a/Lib/test/libregrtest/main.py +++ b/Lib/test/libregrtest/main.py @@ -431,6 +431,14 @@ class Regrtest: duration = time.monotonic() - self.start_time 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: os.system("leaks %d" % os.getpid()) diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index 0b6f2ea..40862e6 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -349,7 +349,7 @@ class BaseTestCase(unittest.TestCase): return list(match.group(1) for match in parser) def check_executed_tests(self, output, tests, skipped=(), failed=(), - omitted=(), randomize=False): + omitted=(), randomize=False, interrupted=False): if isinstance(tests, str): tests = [tests] if isinstance(skipped, str): @@ -398,6 +398,17 @@ class BaseTestCase(unittest.TestCase): regex = 'All %s' % 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): match = self.regex_search(r'Using random seed ([0-9]+)', output) randseed = int(match.group(1)) @@ -658,7 +669,8 @@ class ArgsTestCase(BaseTestCase): code = TEST_INTERRUPTED test = self.create_test('sigint', code=code) 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): # test --slowest @@ -681,10 +693,11 @@ class ArgsTestCase(BaseTestCase): else: args = ("--slowest", test) 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') self.check_line(output, regex) - self.check_line(output, 'Test suite interrupted by signal SIGINT.') def test_coverage(self): # test --coverage -- cgit v0.12