Commit cd70846b authored by Stefan Behnel's avatar Stefan Behnel

add "--failfast" (stop on first failure) mode to test runner (if supported by...

add "--failfast" (stop on first failure) mode to test runner (if supported by Python's unittest module)
parent 4b8cedab
...@@ -1837,6 +1837,9 @@ def main(): ...@@ -1837,6 +1837,9 @@ def main():
parser.add_option("--exit-ok", dest="exit_ok", default=False, parser.add_option("--exit-ok", dest="exit_ok", default=False,
action="store_true", action="store_true",
help="exit without error code even on test failures") help="exit without error code even on test failures")
parser.add_option("--failfast", dest="failfast", default=False,
action="store_true",
help="stop on first failure or error")
parser.add_option("--root-dir", dest="root_dir", default=os.path.join(DISTDIR, 'tests'), parser.add_option("--root-dir", dest="root_dir", default=os.path.join(DISTDIR, 'tests'),
help="working directory") help="working directory")
parser.add_option("--work-dir", dest="work_dir", default=os.path.join(os.getcwd(), 'TEST_TMP'), parser.add_option("--work-dir", dest="work_dir", default=os.path.join(os.getcwd(), 'TEST_TMP'),
...@@ -2137,8 +2140,15 @@ def runtests(options, cmd_args, coverage=None): ...@@ -2137,8 +2140,15 @@ def runtests(options, cmd_args, coverage=None):
except OSError: pass # concurrency issue? except OSError: pass # concurrency issue?
test_runner = XMLTestRunner(output=xml_output_dir, test_runner = XMLTestRunner(output=xml_output_dir,
verbose=options.verbosity > 0) verbose=options.verbosity > 0)
if options.failfast:
sys.stderr.write("--failfast not supported with XML runner")
else:
text_runner_options = {}
if options.failfast and sys.version_info < (2, 7):
sys.stderr.write("--failfast not supported with Python < 2.7")
else: else:
test_runner = unittest.TextTestRunner(verbosity=options.verbosity) text_runner_options['failfast'] = True
test_runner = unittest.TextTestRunner(verbosity=options.verbosity, **text_runner_options)
if options.pyximport_py: if options.pyximport_py:
from pyximport import pyximport from pyximport import pyximport
......
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