Commit a7c33e51 authored by Victor Stinner's avatar Victor Stinner

Issue #12400: regrtest -W doesn't rerun the tests twice anymore, but captures

the output and displays it on failure instead. regrtest -v doesn't print the
error twice anymore if there is only one error.
parent eb5af220
...@@ -25,7 +25,7 @@ Verbosity ...@@ -25,7 +25,7 @@ Verbosity
-v/--verbose -- run tests in verbose mode with output to stdout -v/--verbose -- run tests in verbose mode with output to stdout
-w/--verbose2 -- re-run failed tests in verbose mode -w/--verbose2 -- re-run failed tests in verbose mode
-W/--verbose3 -- re-run failed tests in verbose mode immediately -W/--verbose3 -- display test output on failure
-d/--debug -- print traceback for failed tests -d/--debug -- print traceback for failed tests
-q/--quiet -- no output unless one or more tests fail -q/--quiet -- no output unless one or more tests fail
-S/--slow -- print the slowest 10 tests -S/--slow -- print the slowest 10 tests
...@@ -781,17 +781,27 @@ def runtest(test, verbose, quiet, ...@@ -781,17 +781,27 @@ def runtest(test, verbose, quiet,
PASSED test passed PASSED test passed
""" """
support.verbose = verbose # Tell tests to be moderately quiet
if use_resources is not None: if use_resources is not None:
support.use_resources = use_resources support.use_resources = use_resources
try: try:
result = runtest_inner(test, verbose, quiet, huntrleaks, debug) if rerun_failed:
if result[0] == FAILED and rerun_failed: support.verbose = True
cleanup_test_droppings(test, verbose) orig_stderr = sys.stderr
sys.stdout.flush() with support.captured_stdout() as stream:
sys.stderr.flush() try:
print("Re-running test {} in verbose mode".format(test)) sys.stderr = stream
runtest(test, True, quiet, huntrleaks, debug) result = runtest_inner(test, verbose, quiet, huntrleaks,
debug, display_failure=False)
if result[0] == FAILED:
output = stream.getvalue()
orig_stderr.write(output)
orig_stderr.flush()
finally:
sys.stderr = orig_stderr
else:
support.verbose = verbose # Tell tests to be moderately quiet
result = runtest_inner(test, verbose, quiet, huntrleaks, debug,
display_failure=not verbose)
return result return result
finally: finally:
cleanup_test_droppings(test, verbose) cleanup_test_droppings(test, verbose)
...@@ -960,7 +970,8 @@ class saved_test_environment: ...@@ -960,7 +970,8 @@ class saved_test_environment:
return False return False
def runtest_inner(test, verbose, quiet, huntrleaks=False, debug=False): def runtest_inner(test, verbose, quiet,
huntrleaks=False, debug=False, display_failure=True):
support.unload(test) support.unload(test)
if verbose: if verbose:
capture_stdout = None capture_stdout = None
...@@ -1002,7 +1013,10 @@ def runtest_inner(test, verbose, quiet, huntrleaks=False, debug=False): ...@@ -1002,7 +1013,10 @@ def runtest_inner(test, verbose, quiet, huntrleaks=False, debug=False):
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except support.TestFailed as msg: except support.TestFailed as msg:
print("test", test, "failed --", msg, file=sys.stderr) if display_failure:
print("test", test, "failed --", msg, file=sys.stderr)
else:
print("test", test, "failed", file=sys.stderr)
sys.stderr.flush() sys.stderr.flush()
return FAILED, test_time return FAILED, test_time
except: except:
......
...@@ -122,6 +122,10 @@ Build ...@@ -122,6 +122,10 @@ Build
Tests Tests
----- -----
- Issue #12400: regrtest -W doesn't rerun the tests twice anymore, but captures
the output and displays it on failure instead. regrtest -v doesn't print the
error twice anymore if there is only one error.
- Issue #12141: Install a copy of template C module file so that - Issue #12141: Install a copy of template C module file so that
test_build_ext of test_distutils is no longer silently skipped when test_build_ext of test_distutils is no longer silently skipped when
run outside of a build directory. run outside of a build directory.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment