diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py index 0723c435db5..78c52bd48a3 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 0b6f2ea5376..40862e65894 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