Skip to content

Commit c3cce6c

Browse files
committed
pythongh-108834: regrtest reruns failed tests in subprocesses
Rename --verbose2 option (-w) to --rerun. Keep --verbose2 as a deprecated alias. Changes: * Add RunTests class. * Add TestResult.get_rerun_match_tests() method * Rewrite code to serialize/deserialize worker arguments as JSON using a new WorkerJob class. * Fix stats when a test is run with --forever --rerun. * If failed test names cannot be parsed, log a warning and don't filter tests. * test_regrtest.test_rerun_success() now uses a marker file, since the test is re-run in a separated process. * Add tests on normalize_test_name() function.
1 parent f373c6b commit c3cce6c

10 files changed

+712
-453
lines changed

Lib/test/bisect_cmd.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,10 @@ def parse_args():
109109

110110
def main():
111111
args = parse_args()
112-
if '-w' in args.test_args or '--verbose2' in args.test_args:
113-
print("WARNING: -w/--verbose2 option should not be used to bisect!")
114-
print()
112+
for opt in ('-w', '--rerun', '--verbose2'):
113+
if opt in args.test_args:
114+
print(f"WARNING: {opt} option should not be used to bisect!")
115+
print()
115116

116117
if args.input:
117118
with open(args.input) as fp:

Lib/test/libregrtest/cmdline.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __init__(self, **kwargs) -> None:
156156
self.coverdir = 'coverage'
157157
self.runleaks = False
158158
self.huntrleaks = False
159-
self.verbose2 = False
159+
self.rerun = False
160160
self.verbose3 = False
161161
self.print_slow = False
162162
self.random_seed = None
@@ -213,8 +213,10 @@ def _create_parser():
213213
group = parser.add_argument_group('Verbosity')
214214
group.add_argument('-v', '--verbose', action='count',
215215
help='run tests in verbose mode with output to stdout')
216-
group.add_argument('-w', '--verbose2', action='store_true',
216+
group.add_argument('-w', '--rerun', action='store_true',
217217
help='re-run failed tests in verbose mode')
218+
group.add_argument('--verbose2', action='store_true', dest='rerun',
219+
help='deprecated alias to --rerun')
218220
group.add_argument('-W', '--verbose3', action='store_true',
219221
help='display test output on failure')
220222
group.add_argument('-q', '--quiet', action='store_true',
@@ -380,7 +382,7 @@ def _parse_args(args, **kwargs):
380382
ns.python = shlex.split(ns.python)
381383
if ns.failfast and not (ns.verbose or ns.verbose3):
382384
parser.error("-G/--failfast needs either -v or -W")
383-
if ns.pgo and (ns.verbose or ns.verbose2 or ns.verbose3):
385+
if ns.pgo and (ns.verbose or ns.rerun or ns.verbose3):
384386
parser.error("--pgo/-v don't go together!")
385387
if ns.pgo_extended:
386388
ns.pgo = True # pgo_extended implies pgo

0 commit comments

Comments
 (0)