Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(5)

Unified Diff: Lib/test/regrtest.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/data/README ('k') | Lib/test/support.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/regrtest.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Lib/test/regrtest.py Mon Jul 25 09:47:18 2011 -0400
@@ -30,7 +30,7 @@
-v/--verbose -- run tests in verbose mode with output to stdout
-w/--verbose2 -- re-run failed tests in verbose mode
--W/--verbose3 -- display test output on failure
+-W/--verbose3 -- re-run failed tests in verbose mode immediately
-d/--debug -- print traceback for failed tests
-q/--quiet -- no output unless one or more tests fail
-S/--slow -- print the slowest 10 tests
@@ -43,7 +43,6 @@
-f/--fromfile -- read names of tests to run from a file (see below)
-x/--exclude -- arguments are tests to *exclude*
-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,...
-- specify which special resource intensive tests to run
-M/--memlimit LIMIT
@@ -163,34 +162,24 @@
"""
import builtins
-import errno
import faulthandler
import getopt
-import io
import json
-import logging
import os
-import platform
import random
import re
-import signal
+import io
import sys
+import time
+import errno
+import traceback
+import warnings
+import unittest
+from inspect import isabstract
+import tempfile
+import platform
import sysconfig
-import tempfile
-import time
-import traceback
-import unittest
-import warnings
-from inspect import isabstract
-
-try:
- import threading
-except ImportError:
- threading = None
-try:
- import multiprocessing.process
-except ImportError:
- multiprocessing = None
+import logging
# Some times __path__ and __file__ are not absolute (e.g. while running from
@@ -253,7 +242,7 @@
findleaks=False, use_resources=None, trace=False, coverdir='coverage',
runleaks=False, huntrleaks=False, verbose2=False, print_slow=False,
random_seed=None, use_mp=None, verbose3=False, forever=False,
- header=False, failfast=False):
+ header=False):
"""Execute a test suite.
This also parses command-line options and modifies its behavior
@@ -277,30 +266,20 @@
on the command line.
"""
- # Display the Python traceback on fatal errors (e.g. segfault)
+ # Display the Python traceback fatal errors (e.g. segfault)
faulthandler.enable(all_threads=True)
- # Display the Python traceback on SIGALRM or SIGUSR1 signal
- signals = []
- if hasattr(signal, 'SIGALRM'):
- signals.append(signal.SIGALRM)
- if hasattr(signal, 'SIGUSR1'):
- signals.append(signal.SIGUSR1)
- for signum in signals:
- faulthandler.register(signum, chain=True)
-
replace_stdout()
support.record_original_stdout(sys.stdout)
try:
- opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:nj:G',
+ opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:nj:',
['help', 'verbose', 'verbose2', 'verbose3', 'quiet',
'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks',
'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir',
'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=',
'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug',
- 'start=', 'nowindows', 'header', 'testdir=', 'timeout=', 'wait',
- 'failfast'])
+ 'start=', 'nowindows', 'header', 'testdir=', 'timeout=', 'wait'])
except getopt.error as msg:
usage(msg)
@@ -324,8 +303,6 @@
debug = True
elif o in ('-W', '--verbose3'):
verbose3 = True
- elif o in ('-G', '--failfast'):
- failfast = True
elif o in ('-q', '--quiet'):
quiet = True;
verbose = 0
@@ -458,8 +435,6 @@
usage("-T and -j don't go together!")
if use_mp and findleaks:
usage("-l and -j don't go together!")
- if failfast and not (verbose or verbose3):
- usage("-G/--failfast needs either -v or -W")
good = []
bad = []
@@ -605,8 +580,7 @@
args_tuple = (
(test, verbose, quiet),
dict(huntrleaks=huntrleaks, use_resources=use_resources,
- debug=debug, output_on_failure=verbose3,
- timeout=timeout, failfast=failfast)
+ debug=debug, rerun_failed=verbose3, timeout=timeout)
)
yield (test, args_tuple)
pending = tests_and_args()
@@ -691,8 +665,7 @@
else:
try:
result = runtest(test, verbose, quiet, huntrleaks, debug,
- output_on_failure=verbose3,
- timeout=timeout, failfast=failfast)
+ rerun_failed=verbose3, timeout=timeout)
accumulate_result(test, result)
except KeyboardInterrupt:
interrupted = True
@@ -836,7 +809,7 @@
def runtest(test, verbose, quiet,
huntrleaks=False, debug=False, use_resources=None,
- output_on_failure=False, failfast=False, timeout=None):
+ rerun_failed=False, timeout=None):
"""Run a single test.
test -- the name of the test
@@ -845,7 +818,7 @@
test_times -- a list of (time, test_name) pairs
huntrleaks -- run multiple times to test for leaks; requires a debug
build; a triple corresponding to -R's three arguments
- output_on_failure -- if true, display test output on failure
+ rerun_failed -- if true, re-run in verbose mode when failed
timeout -- dump the traceback and exit if a test takes more than
timeout seconds
@@ -858,52 +831,25 @@
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:
- if failfast:
- support.failfast = True
- if output_on_failure:
- support.verbose = True
-
- # Reuse the same instance to all calls to runtest(). Some
- # tests keep a reference to sys.stdout or sys.stderr
- # (eg. test_argparse).
- if runtest.stringio is None:
- stream = io.StringIO()
- runtest.stringio = stream
- else:
- stream = runtest.stringio
- stream.seek(0)
- stream.truncate()
-
- orig_stdout = sys.stdout
- orig_stderr = sys.stderr
- try:
- sys.stdout = stream
- 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.stdout = orig_stdout
- 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)
+ 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)
return result
finally:
if use_timeout:
faulthandler.cancel_dump_tracebacks_later()
cleanup_test_droppings(test, verbose)
-runtest.stringio = None
# Unit tests are supposed to leave the execution environment unchanged
# once they complete. But sometimes tests have bugs, especially when
@@ -948,8 +894,7 @@
'os.environ', 'sys.path', 'sys.path_hooks', '__import__',
'warnings.filters', 'asyncore.socket_map',
'logging._handlers', 'logging._handlerList', 'sys.gettrace',
- 'sys.warnoptions', 'threading._dangling',
- 'multiprocessing.process._dangling')
+ 'sys.warnoptions')
def get_sys_argv(self):
return id(sys.argv), sys.argv, sys.argv[:]
@@ -1042,31 +987,6 @@
sys.warnoptions = saved_options[1]
sys.warnoptions[:] = saved_options[2]
- # Controlling dangling references to Thread objects can make it easier
- # to track reference leaks.
- def get_threading__dangling(self):
- if not threading:
- return None
- # This copies the weakrefs without making any strong reference
- return threading._dangling.copy()
- def restore_threading__dangling(self, saved):
- if not threading:
- return
- threading._dangling.clear()
- threading._dangling.update(saved)
-
- # Same for Process objects
- def get_multiprocessing_process__dangling(self):
- if not multiprocessing:
- return None
- # This copies the weakrefs without making any strong reference
- return multiprocessing.process._dangling.copy()
- def restore_multiprocessing_process__dangling(self, saved):
- if not multiprocessing:
- return
- multiprocessing.process._dangling.clear()
- multiprocessing.process._dangling.update(saved)
-
def resource_info(self):
for name in self.resources:
method_suffix = name.replace('.', '_')
@@ -1100,8 +1020,7 @@
return False
-def runtest_inner(test, verbose, quiet,
- huntrleaks=False, debug=False, display_failure=True):
+def runtest_inner(test, verbose, quiet, huntrleaks=False, debug=False):
support.unload(test)
test_time = 0.0
@@ -1139,10 +1058,7 @@
except KeyboardInterrupt:
raise
except support.TestFailed as msg:
- if display_failure:
- print("test", test, "failed --", msg, file=sys.stderr)
- else:
- print("test", test, "failed", file=sys.stderr)
+ print("test", test, "failed --", msg, file=sys.stderr)
sys.stderr.flush()
return FAILED, test_time
except:
« no previous file with comments | « Lib/test/data/README ('k') | Lib/test/support.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+