summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-22 12:28:52 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-08-22 12:28:52 (GMT)
commitab983677470393c4b30f3b68985156f3e2b47a6f (patch)
tree672e132b973c08fcb2da4930e55a55fc15896fc8 /Lib
parentb820d7f63132c1c6c1f301ee40be2b2729a61356 (diff)
downloadcpython-ab983677470393c4b30f3b68985156f3e2b47a6f.zip
cpython-ab983677470393c4b30f3b68985156f3e2b47a6f.tar.gz
cpython-ab983677470393c4b30f3b68985156f3e2b47a6f.tar.bz2
Cleanup libregrtest
* main.py: remove unused import * runtest: simplify runtest_inner() parameters, reuse ns parameter
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/libregrtest/main.py1
-rw-r--r--Lib/test/libregrtest/runtest.py56
2 files changed, 20 insertions, 37 deletions
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index b9d7ab4..ba9e48b 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -1,6 +1,5 @@
import datetime
import faulthandler
-import math
import os
import platform
import random
diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py
index ef1feb7..7d5290e 100644
--- a/Lib/test/libregrtest/runtest.py
+++ b/Lib/test/libregrtest/runtest.py
@@ -74,18 +74,12 @@ def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
def runtest(ns, test):
"""Run a single test.
+ ns -- regrtest namespace of options
test -- the name of the test
- verbose -- if true, print more messages
- quiet -- if true, don't print 'skipped' messages (probably redundant)
- 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
- timeout -- dump the traceback and exit if a test takes more than
- timeout seconds
- failfast, match_tests -- See regrtest command-line flags for these.
- pgo -- if true, suppress any info irrelevant to a generating a PGO build
- Returns the tuple result, test_time, where result is one of the constants:
+ Returns the tuple (result, test_time), where result is one of the
+ constants:
+
INTERRUPTED KeyboardInterrupt when run under -j
RESOURCE_DENIED test skipped because resource denied
SKIPPED test skipped for some other reason
@@ -94,21 +88,14 @@ def runtest(ns, test):
PASSED test passed
"""
- verbose = ns.verbose
- quiet = ns.quiet
- huntrleaks = ns.huntrleaks
output_on_failure = ns.verbose3
- failfast = ns.failfast
- match_tests = ns.match_tests
- timeout = ns.timeout
- pgo = ns.pgo
- use_timeout = (timeout is not None)
+ use_timeout = (ns.timeout is not None)
if use_timeout:
- faulthandler.dump_traceback_later(timeout, exit=True)
+ faulthandler.dump_traceback_later(ns.timeout, exit=True)
try:
- support.match_tests = match_tests
- if failfast:
+ support.match_tests = ns.match_tests
+ if ns.failfast:
support.failfast = True
if output_on_failure:
support.verbose = True
@@ -129,8 +116,7 @@ def runtest(ns, test):
try:
sys.stdout = stream
sys.stderr = stream
- result = runtest_inner(ns, test, verbose, quiet, huntrleaks,
- display_failure=False, pgo=pgo)
+ result = runtest_inner(ns, test, display_failure=False)
if result[0] == FAILED:
output = stream.getvalue()
orig_stderr.write(output)
@@ -139,19 +125,17 @@ def runtest(ns, test):
sys.stdout = orig_stdout
sys.stderr = orig_stderr
else:
- support.verbose = verbose # Tell tests to be moderately quiet
- result = runtest_inner(ns, test, verbose, quiet, huntrleaks,
- display_failure=not verbose, pgo=pgo)
+ support.verbose = ns.verbose # Tell tests to be moderately quiet
+ result = runtest_inner(ns, test, display_failure=not ns.verbose)
return result
finally:
if use_timeout:
faulthandler.cancel_dump_traceback_later()
- cleanup_test_droppings(test, verbose)
+ cleanup_test_droppings(test, ns.verbose)
runtest.stringio = None
-def runtest_inner(ns, test, verbose, quiet,
- huntrleaks=False, display_failure=True, *, pgo=False):
+def runtest_inner(ns, test, display_failure=True):
support.unload(test)
test_time = 0.0
@@ -162,7 +146,7 @@ def runtest_inner(ns, test, verbose, quiet,
else:
# Always import it from the test package
abstest = 'test.' + test
- with saved_test_environment(test, verbose, quiet, pgo=pgo) as environment:
+ with saved_test_environment(test, ns.verbose, ns.quiet, pgo=ns.pgo) as environment:
start_time = time.time()
the_module = importlib.import_module(abstest)
# If the test has a test_main, that will run the appropriate
@@ -178,21 +162,21 @@ def runtest_inner(ns, test, verbose, quiet,
raise Exception("errors while loading tests")
support.run_unittest(tests)
test_runner()
- if huntrleaks:
- refleak = dash_R(the_module, test, test_runner, huntrleaks)
+ if ns.huntrleaks:
+ refleak = dash_R(the_module, test, test_runner, ns.huntrleaks)
test_time = time.time() - start_time
except support.ResourceDenied as msg:
- if not quiet and not pgo:
+ if not ns.quiet and not ns.pgo:
print(test, "skipped --", msg, flush=True)
return RESOURCE_DENIED, test_time
except unittest.SkipTest as msg:
- if not quiet and not pgo:
+ if not ns.quiet and not ns.pgo:
print(test, "skipped --", msg, flush=True)
return SKIPPED, test_time
except KeyboardInterrupt:
raise
except support.TestFailed as msg:
- if not pgo:
+ if not ns.pgo:
if display_failure:
print("test", test, "failed --", msg, file=sys.stderr,
flush=True)
@@ -201,7 +185,7 @@ def runtest_inner(ns, test, verbose, quiet,
return FAILED, test_time
except:
msg = traceback.format_exc()
- if not pgo:
+ if not ns.pgo:
print("test", test, "crashed --", msg, file=sys.stderr,
flush=True)
return FAILED, test_time