mirror of https://github.com/python/cpython
Issue #12624: It is now possible to fail after the first failure when
running in verbose mode (`-v` or `-W`), by using the `--failfast` (or `-G`) option to regrtest. This is useful with long test suites such as test_io or test_subprocess.
This commit is contained in:
commit
8dbd8573e5
|
@ -43,6 +43,7 @@ Selecting tests
|
||||||
-f/--fromfile -- read names of tests to run from a file (see below)
|
-f/--fromfile -- read names of tests to run from a file (see below)
|
||||||
-x/--exclude -- arguments are tests to *exclude*
|
-x/--exclude -- arguments are tests to *exclude*
|
||||||
-s/--single -- single step through a set of tests (see below)
|
-s/--single -- single step through a set of tests (see below)
|
||||||
|
-G/--failfast -- fail as soon as a test fails (only with -v or -W)
|
||||||
-u/--use RES1,RES2,...
|
-u/--use RES1,RES2,...
|
||||||
-- specify which special resource intensive tests to run
|
-- specify which special resource intensive tests to run
|
||||||
-M/--memlimit LIMIT
|
-M/--memlimit LIMIT
|
||||||
|
@ -252,7 +253,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
findleaks=False, use_resources=None, trace=False, coverdir='coverage',
|
findleaks=False, use_resources=None, trace=False, coverdir='coverage',
|
||||||
runleaks=False, huntrleaks=False, verbose2=False, print_slow=False,
|
runleaks=False, huntrleaks=False, verbose2=False, print_slow=False,
|
||||||
random_seed=None, use_mp=None, verbose3=False, forever=False,
|
random_seed=None, use_mp=None, verbose3=False, forever=False,
|
||||||
header=False):
|
header=False, failfast=False):
|
||||||
"""Execute a test suite.
|
"""Execute a test suite.
|
||||||
|
|
||||||
This also parses command-line options and modifies its behavior
|
This also parses command-line options and modifies its behavior
|
||||||
|
@ -292,13 +293,14 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
|
|
||||||
support.record_original_stdout(sys.stdout)
|
support.record_original_stdout(sys.stdout)
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:nj:',
|
opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:nj:G',
|
||||||
['help', 'verbose', 'verbose2', 'verbose3', 'quiet',
|
['help', 'verbose', 'verbose2', 'verbose3', 'quiet',
|
||||||
'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks',
|
'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks',
|
||||||
'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir',
|
'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir',
|
||||||
'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=',
|
'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=',
|
||||||
'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug',
|
'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug',
|
||||||
'start=', 'nowindows', 'header', 'testdir=', 'timeout=', 'wait'])
|
'start=', 'nowindows', 'header', 'testdir=', 'timeout=', 'wait',
|
||||||
|
'failfast'])
|
||||||
except getopt.error as msg:
|
except getopt.error as msg:
|
||||||
usage(msg)
|
usage(msg)
|
||||||
|
|
||||||
|
@ -322,6 +324,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
debug = True
|
debug = True
|
||||||
elif o in ('-W', '--verbose3'):
|
elif o in ('-W', '--verbose3'):
|
||||||
verbose3 = True
|
verbose3 = True
|
||||||
|
elif o in ('-G', '--failfast'):
|
||||||
|
failfast = True
|
||||||
elif o in ('-q', '--quiet'):
|
elif o in ('-q', '--quiet'):
|
||||||
quiet = True;
|
quiet = True;
|
||||||
verbose = 0
|
verbose = 0
|
||||||
|
@ -454,6 +458,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
usage("-T and -j don't go together!")
|
usage("-T and -j don't go together!")
|
||||||
if use_mp and findleaks:
|
if use_mp and findleaks:
|
||||||
usage("-l and -j don't go together!")
|
usage("-l and -j don't go together!")
|
||||||
|
if failfast and not (verbose or verbose3):
|
||||||
|
usage("-G/--failfast needs either -v or -W")
|
||||||
|
|
||||||
good = []
|
good = []
|
||||||
bad = []
|
bad = []
|
||||||
|
@ -600,7 +606,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
(test, verbose, quiet),
|
(test, verbose, quiet),
|
||||||
dict(huntrleaks=huntrleaks, use_resources=use_resources,
|
dict(huntrleaks=huntrleaks, use_resources=use_resources,
|
||||||
debug=debug, output_on_failure=verbose3,
|
debug=debug, output_on_failure=verbose3,
|
||||||
timeout=timeout)
|
timeout=timeout, failfast=failfast)
|
||||||
)
|
)
|
||||||
yield (test, args_tuple)
|
yield (test, args_tuple)
|
||||||
pending = tests_and_args()
|
pending = tests_and_args()
|
||||||
|
@ -685,7 +691,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
result = runtest(test, verbose, quiet, huntrleaks, debug,
|
result = runtest(test, verbose, quiet, huntrleaks, debug,
|
||||||
output_on_failure=verbose3, timeout=timeout)
|
output_on_failure=verbose3,
|
||||||
|
timeout=timeout, failfast=failfast)
|
||||||
accumulate_result(test, result)
|
accumulate_result(test, result)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
interrupted = True
|
interrupted = True
|
||||||
|
@ -829,7 +836,7 @@ def replace_stdout():
|
||||||
|
|
||||||
def runtest(test, verbose, quiet,
|
def runtest(test, verbose, quiet,
|
||||||
huntrleaks=False, debug=False, use_resources=None,
|
huntrleaks=False, debug=False, use_resources=None,
|
||||||
output_on_failure=False, timeout=None):
|
output_on_failure=False, failfast=False, timeout=None):
|
||||||
"""Run a single test.
|
"""Run a single test.
|
||||||
|
|
||||||
test -- the name of the test
|
test -- the name of the test
|
||||||
|
@ -857,6 +864,8 @@ def runtest(test, verbose, quiet,
|
||||||
if use_timeout:
|
if use_timeout:
|
||||||
faulthandler.dump_tracebacks_later(timeout, exit=True)
|
faulthandler.dump_tracebacks_later(timeout, exit=True)
|
||||||
try:
|
try:
|
||||||
|
if failfast:
|
||||||
|
support.failfast = True
|
||||||
if output_on_failure:
|
if output_on_failure:
|
||||||
support.verbose = True
|
support.verbose = True
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ __all__ = [
|
||||||
"threading_cleanup", "reap_children", "cpython_only", "check_impl_detail",
|
"threading_cleanup", "reap_children", "cpython_only", "check_impl_detail",
|
||||||
"get_attribute", "swap_item", "swap_attr", "requires_IEEE_754",
|
"get_attribute", "swap_item", "swap_attr", "requires_IEEE_754",
|
||||||
"TestHandler", "Matcher", "can_symlink", "skip_unless_symlink",
|
"TestHandler", "Matcher", "can_symlink", "skip_unless_symlink",
|
||||||
"import_fresh_module", "requires_zlib", "PIPE_MAX_SIZE"
|
"import_fresh_module", "requires_zlib", "PIPE_MAX_SIZE", "failfast",
|
||||||
]
|
]
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
|
@ -179,6 +179,7 @@ use_resources = None # Flag set to [] by regrtest.py
|
||||||
max_memuse = 0 # Disable bigmem tests (they will still be run with
|
max_memuse = 0 # Disable bigmem tests (they will still be run with
|
||||||
# small sizes, to make sure they work.)
|
# small sizes, to make sure they work.)
|
||||||
real_max_memuse = 0
|
real_max_memuse = 0
|
||||||
|
failfast = False
|
||||||
|
|
||||||
# _original_stdout is meant to hold stdout at the time regrtest began.
|
# _original_stdout is meant to hold stdout at the time regrtest began.
|
||||||
# This may be "the real" stdout, or IDLE's emulation of stdout, or whatever.
|
# This may be "the real" stdout, or IDLE's emulation of stdout, or whatever.
|
||||||
|
@ -1270,7 +1271,8 @@ def refcount_test(test):
|
||||||
def _run_suite(suite):
|
def _run_suite(suite):
|
||||||
"""Run tests from a unittest.TestSuite-derived class."""
|
"""Run tests from a unittest.TestSuite-derived class."""
|
||||||
if verbose:
|
if verbose:
|
||||||
runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
|
runner = unittest.TextTestRunner(sys.stdout, verbosity=2,
|
||||||
|
failfast=failfast)
|
||||||
else:
|
else:
|
||||||
runner = BasicTestRunner()
|
runner = BasicTestRunner()
|
||||||
|
|
||||||
|
|
|
@ -1087,6 +1087,11 @@ Extension Modules
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Issue #12624: It is now possible to fail after the first failure when
|
||||||
|
running in verbose mode (``-v`` or ``-W``), by using the ``--failfast``
|
||||||
|
(or ``-G``) option to regrtest. This is useful with long test suites
|
||||||
|
such as test_io or test_subprocess.
|
||||||
|
|
||||||
- Issue #12587: Correct faulty test file and reference in test_tokenize.
|
- Issue #12587: Correct faulty test file and reference in test_tokenize.
|
||||||
(Patch by Robert Xiao)
|
(Patch by Robert Xiao)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue