summaryrefslogtreecommitdiff
path: root/Lib/test/libregrtest
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-05-20 13:37:40 +0200
committerVictor Stinner <victor.stinner@gmail.com>2016-05-20 13:37:40 +0200
commit71708a1f46c80b4e3e467c23f6ce482b2bf3c8e3 (patch)
tree9c185a224b7fdf998af3bce2d6b5e2870486f3c2 /Lib/test/libregrtest
parent50da51f9515e09c03f391b95604a9c50ab2a3ec6 (diff)
downloadcpython-71708a1f46c80b4e3e467c23f6ce482b2bf3c8e3.tar.gz
regrtest: display test result (passed, failed, ...)
* in multiprocessing mode: always display the result * sequential mode: only display the result if the test did not pass
Diffstat (limited to 'Lib/test/libregrtest')
-rw-r--r--Lib/test/libregrtest/main.py12
-rw-r--r--Lib/test/libregrtest/runtest.py17
-rw-r--r--Lib/test/libregrtest/runtest_mp.py5
3 files changed, 26 insertions, 8 deletions
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 447d99f88a..e503c131ac 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -15,7 +15,7 @@ from test.libregrtest.runtest import (
findtests, runtest,
STDTESTS, NOTTESTS, PASSED, FAILED, ENV_CHANGED, SKIPPED, RESOURCE_DENIED,
INTERRUPTED, CHILD_ERROR,
- PROGRESS_MIN_TIME)
+ PROGRESS_MIN_TIME, format_test_result)
from test.libregrtest.setup import setup_tests
from test import support
try:
@@ -326,7 +326,9 @@ class Regrtest:
# if on a false return value from main.
cmd = ('result = runtest(self.ns, test); '
'self.accumulate_result(test, result)')
- self.tracer.runctx(cmd, globals=globals(), locals=vars())
+ ns = dict(locals())
+ self.tracer.runctx(cmd, globals=globals(), locals=ns)
+ result = ns['result']
else:
try:
result = runtest(self.ns, test)
@@ -337,10 +339,12 @@ class Regrtest:
else:
self.accumulate_result(test, result)
+ previous_test = format_test_result(test, result[0])
test_time = time.monotonic() - start_time
if test_time >= PROGRESS_MIN_TIME:
- previous_test = '%s took %.0f sec' % (test, test_time)
- else:
+ previous_test = "%s in %.0f sec" % (previous_test, test_time)
+ elif result[0] == PASSED:
+ # be quiet: say nothing if the test passed shortly
previous_test = None
if self.ns.findleaks:
diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py
index 601f2b26ec..ef1feb738a 100644
--- a/Lib/test/libregrtest/runtest.py
+++ b/Lib/test/libregrtest/runtest.py
@@ -20,12 +20,20 @@ RESOURCE_DENIED = -3
INTERRUPTED = -4
CHILD_ERROR = -5 # error in a child process
+_FORMAT_TEST_RESULT = {
+ PASSED: '%s passed',
+ FAILED: '%s failed',
+ ENV_CHANGED: '%s failed (env changed)',
+ SKIPPED: '%s skipped',
+ RESOURCE_DENIED: '%s skipped (resource denied)',
+ INTERRUPTED: '%s interrupted',
+ CHILD_ERROR: '%s crashed',
+}
+
# Minimum duration of a test to display its duration or to mention that
# the test is running in background
PROGRESS_MIN_TIME = 30.0 # seconds
-
-
# small set of tests to determine if we have a basically functioning interpreter
# (i.e. if any of these fail, then anything else is likely to follow)
STDTESTS = [
@@ -45,6 +53,11 @@ STDTESTS = [
NOTTESTS = set()
+def format_test_result(test_name, result):
+ fmt = _FORMAT_TEST_RESULT.get(result, "%s")
+ return fmt % test_name
+
+
def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
"""Return a list of all applicable test modules."""
testdir = findtestdir(testdir)
diff --git a/Lib/test/libregrtest/runtest_mp.py b/Lib/test/libregrtest/runtest_mp.py
index 33f632d47a..9604c16600 100644
--- a/Lib/test/libregrtest/runtest_mp.py
+++ b/Lib/test/libregrtest/runtest_mp.py
@@ -14,7 +14,8 @@ except ImportError:
sys.exit(2)
from test.libregrtest.runtest import (
- runtest, INTERRUPTED, CHILD_ERROR, PROGRESS_MIN_TIME)
+ runtest, INTERRUPTED, CHILD_ERROR, PROGRESS_MIN_TIME,
+ format_test_result)
from test.libregrtest.setup import setup_tests
@@ -196,8 +197,8 @@ def run_tests_multiprocess(regrtest):
regrtest.accumulate_result(test, result)
# Display progress
- text = test
ok, test_time = result
+ text = format_test_result(test, ok)
if (ok not in (CHILD_ERROR, INTERRUPTED)
and test_time >= PROGRESS_MIN_TIME
and not regrtest.ns.pgo):