◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
3 changes: 3 additions & 0 deletions Lib/test/libregrtest/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ def _create_parser():
' , don\'t execute them')
group.add_argument('-P', '--pgo', dest='pgo', action='store_true',
help='enable Profile Guided Optimization training')

return parser

Expand Down
10 changes: 9 additions & 1 deletion Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ def finalize(self):
result = "FAILURE"
elif self.interrupted:
result = "INTERRUPTED"
else:
result = "SUCCESS"
print("Tests result: %s" % result)
Expand Down Expand Up @@ -538,7 +540,13 @@ def _main(self, tests, kwargs):
self.rerun_failed_tests()

self.finalize()
sys.exit(len(self.bad) > 0 or self.interrupted)


def removepy(names):
Expand Down
53 changes: 40 additions & 13 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,19 +377,19 @@ def parse_executed_tests(self, output):
return list(match.group(1) for match in parser)

def check_executed_tests(self, output, tests, skipped=(), failed=(),
omitted=(), randomize=False, interrupted=False):
if isinstance(tests, str):
tests = [tests]
if isinstance(skipped, str):
skipped = [skipped]
if isinstance(failed, str):
failed = [failed]
if isinstance(omitted, str):
omitted = [omitted]
ntest = len(tests)
nskipped = len(skipped)
nfailed = len(failed)
nomitted = len(omitted)

executed = self.parse_executed_tests(output)
if randomize:
Expand All @@ -415,11 +415,17 @@ def list_regex(line_format, tests):
regex = list_regex('%s test%s failed', failed)
self.check_line(output, regex)

if omitted:
regex = list_regex('%s test%s omitted', omitted)
self.check_line(output, regex)

good = ntest - nskipped - nfailed - nomitted
if good:
regex = r'%s test%s OK\.$' % (good, plural(good))
if not skipped and not failed and good > 1:
Expand All @@ -429,10 +435,12 @@ def list_regex(line_format, tests):
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, 'Tests result: %s' % result)
Expand Down Expand Up @@ -604,7 +612,7 @@ def test_failing(self):
test_failing = self.create_test('failing', code=code)
tests = [test_ok, test_failing]

output = self.run_tests(*tests, exitcode=1)
self.check_executed_tests(output, tests, failed=test_failing)

def test_resources(self):
Expand Down Expand Up @@ -703,7 +711,7 @@ def test_fromfile(self):
def test_interrupted(self):
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,
interrupted=True)

Expand Down Expand Up @@ -732,7 +740,7 @@ def test_slow_interrupted(self):
args = ("--slowest", "-j2", test)
else:
args = ("--slowest", test)
output = self.run_tests(*args, exitcode=1)
self.check_executed_tests(output, test,
omitted=test, interrupted=True)

Expand Down Expand Up @@ -772,7 +780,7 @@ def test_run(self):
builtins.__dict__['RUN'] = 1
""")
test = self.create_test('forever', code=code)
output = self.run_tests('--forever', test, exitcode=1)
self.check_executed_tests(output, [test]*3, failed=test)

@unittest.skipUnless(Py_DEBUG, 'need a debug build')
Expand Down Expand Up @@ -804,7 +812,7 @@ def test_leak(self):
filename = 'reflog.txt'
self.addCleanup(support.unlink, filename)
output = self.run_tests('--huntrleaks', '3:3:', test,
exitcode=1,
stderr=subprocess.STDOUT)
self.check_executed_tests(output, [test], failed=test)

Expand Down Expand Up @@ -858,7 +866,7 @@ def test_crashed(self):
ok_test = self.create_test(name="ok")

tests = [crash_test, ok_test]
output = self.run_tests("-j2", *tests, exitcode=1)
self.check_executed_tests(output, tests, failed=crash_test,
randomize=True)

Expand Down Expand Up @@ -907,6 +915,25 @@ def test_method4(self):
subset = ['test_method1', 'test_method3']
self.assertEqual(methods, subset)


if __name__ == '__main__':
unittest.main()
Toggle all file notes Toggle all file annotations