From: Victor Stinner Date: Wed, 29 Jun 2011 11:04:35 +0000 (+0200) Subject: (merge 3.2) Issue #12400: regrtest -W doesn't rerun the tests twice anymore, X-Git-Tag: v3.3.0a1~2019 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2185d714bf541ab37e7ddec5fb2f452fdeb26be;p=python (merge 3.2) 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. --- e2185d714bf541ab37e7ddec5fb2f452fdeb26be diff --cc Lib/test/regrtest.py index 968b59df5a,2929001359..62d869c41a --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@@ -831,24 -781,29 +831,34 @@@ def runtest(test, verbose, quiet PASSED test passed """ - support.verbose = verbose # Tell tests to be moderately quiet if use_resources is not None: support.use_resources = use_resources + use_timeout = (timeout is not None) + if use_timeout: + faulthandler.dump_tracebacks_later(timeout, exit=True) try: - result = runtest_inner(test, verbose, quiet, huntrleaks, debug) - if result[0] == FAILED and rerun_failed: - cleanup_test_droppings(test, verbose) - sys.stdout.flush() - sys.stderr.flush() - print("Re-running test {} in verbose mode".format(test)) - runtest(test, True, quiet, huntrleaks, debug, timeout=timeout) + if rerun_failed: + support.verbose = True + orig_stderr = sys.stderr + with support.captured_stdout() as stream: + try: + sys.stderr = stream + 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 finally: + if use_timeout: + faulthandler.cancel_dump_tracebacks_later() cleanup_test_droppings(test, verbose) # Unit tests are supposed to leave the execution environment unchanged @@@ -1020,8 -970,13 +1030,9 @@@ class saved_test_environment 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) - if verbose: - capture_stdout = None - else: - capture_stdout = io.StringIO() test_time = 0.0 refleak = False # True if the test leaked references. diff --cc Lib/test/test_os.py index 13dc337e3e,f58a5c1647..e075a6b3fc --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@@ -40,6 -35,6 +40,7 @@@ class FileTests(unittest.TestCase) tearDown = setUp def test_access(self): ++ self.assertEqual(1,2) f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR) os.close(f) self.assertTrue(os.access(support.TESTFN, os.W_OK)) diff --cc Misc/NEWS index 282dc5ac0c,51a7d57a3e..ce31628c52 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -924,36 -567,6 +924,40 @@@ Extension Module 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 copies of template C module file so that + test_build_ext of test_distutils and test_command_build_ext of + test_packaging are no longer silently skipped when + run outside of a build directory. + +- Issue #8746: Add additional tests for os.chflags() and os.lchflags(). + Patch by Garrett Cooper. + +- Issue #10736: Fix test_ttk test_widgets failures with Cocoa Tk 8.5.9 + 2.8 + on Mac OS X. (Patch by Ronald Oussoren) + +- Issue #12057: Add tests for ISO 2022 codecs (iso2022_jp, iso2022_jp_2, + iso2022_kr). + +- Issue #12180: Fixed a few remaining errors in test_packaging when no + threading. + +- Issue #12120, #12119: skip a test in packaging and distutils + if sys.dont_write_bytecode is set to True. + +- Issue #12096: Fix a race condition in test_threading.test_waitfor(). Patch + written by Charles-François Natali. + +- Issue #11614: import __hello__ prints "Hello World!". Patch written by + Andreas Stührk. + +- Issue #5723: Improve json tests to be executed with and without accelerations. + +- Issue #12041: Make test_wait3 more robust. + - Issue #11873: Change regex in test_compileall to fix occasional failures when when the randomly generated temporary path happened to match the regex.