Commit d59c1c9e authored by Jason Madden's avatar Jason Madden

Add --quiet option to testrunner.py and use it on CI

Fixes #926
parent ca16b43f
......@@ -74,12 +74,12 @@ test_prelim:
make bench
toxtest: test_prelim
cd src/greentest && GEVENT_RESOLVER=thread ${PYTHON} testrunner.py --config known_failures.py
cd src/greentest && GEVENT_RESOLVER=thread ${PYTHON} testrunner.py --config known_failures.py --quiet
fulltoxtest: test_prelim
cd src/greentest && GEVENT_RESOLVER=thread ${PYTHON} testrunner.py --config known_failures.py
cd src/greentest && GEVENT_RESOLVER=ares GEVENTARES_SERVERS=8.8.8.8 ${PYTHON} testrunner.py --config known_failures.py --ignore tests_that_dont_use_resolver.txt
cd src/greentest && GEVENT_FILE=thread ${PYTHON} testrunner.py --config known_failures.py `grep -l subprocess test_*.py`
cd src/greentest && GEVENT_RESOLVER=thread ${PYTHON} testrunner.py --config known_failures.py --quiet
cd src/greentest && GEVENT_RESOLVER=ares GEVENTARES_SERVERS=8.8.8.8 ${PYTHON} testrunner.py --config known_failures.py --ignore tests_that_dont_use_resolver.txt --quiet
cd src/greentest && GEVENT_FILE=thread ${PYTHON} testrunner.py --config known_failures.py `grep -l subprocess test_*.py` --quiet
leaktest:
GEVENTSETUP_EV_VERIFY=3 GEVENTTEST_LEAKCHECK=1 make fulltoxtest
......
......@@ -145,7 +145,7 @@ build_script:
test_script:
# Run the project tests
- "cd src/greentest && %PYEXE% testrunner.py --config known_failures.py && cd ../.."
- "cd src/greentest && %PYEXE% testrunner.py --config known_failures.py --quiet && cd ../.."
after_test:
# We already built the wheel during build_script, because it's
......
......@@ -45,7 +45,7 @@ IGNORE_COVERAGE = [
]
def run_many(tests, expected=(), failfast=False):
def run_many(tests, expected=(), failfast=False, quiet=False):
# pylint:disable=too-many-locals
global NWORKERS
start = time.time()
......@@ -59,6 +59,7 @@ def run_many(tests, expected=(), failfast=False):
util.BUFFER_OUTPUT = NWORKERS > 1
def run_one(cmd, **kwargs):
kwargs['quiet'] = quiet
result = util.run(cmd, **kwargs)
if result:
if failfast:
......@@ -84,7 +85,7 @@ def run_many(tests, expected=(), failfast=False):
while reap() > 0:
time.sleep(0.1)
def spawn(args, kwargs): # pylint:disable=unused-argument
def spawn(cmd, options):
while True:
if reap() < NWORKERS:
r = pool.apply_async(run_one, (cmd, ), options or {})
......@@ -103,7 +104,7 @@ def run_many(tests, expected=(), failfast=False):
if matches(RUN_ALONE, cmd):
run_alone.append((cmd, options))
else:
spawn((cmd, ), options)
spawn(cmd, options)
pool.close()
pool.join()
......@@ -276,6 +277,7 @@ def main():
parser.add_option('--config')
parser.add_option('--failfast', action='store_true')
parser.add_option("--coverage", action="store_true")
parser.add_option("--quiet", action="store_true")
options, args = parser.parse_args()
FAILING_TESTS = []
coverage = False
......@@ -301,7 +303,7 @@ def main():
print(util.getname(cmd, env=options.get('env'), setenv=options.get('setenv')))
print('%s tests found.' % len(tests))
else:
run_many(tests, expected=FAILING_TESTS, failfast=options.failfast)
run_many(tests, expected=FAILING_TESTS, failfast=options.failfast, quiet=options.quiet)
if __name__ == '__main__':
......
......@@ -12,6 +12,7 @@ import time
runtimelog = []
MIN_RUNTIME = 1.0
BUFFER_OUTPUT = False
QUIET = False
class Popen(subprocess.Popen):
......@@ -158,12 +159,11 @@ class RunResult(object):
self.output = output
self.name = name
if six.PY3:
def __bool__(self):
return bool(self.code)
else:
def __nonzero__(self):
return bool(self.code)
def __bool__(self):
return bool(self.code)
__nonzero__ = __bool__
def __int__(self):
return self.code
......@@ -174,6 +174,8 @@ lock = threading.Lock()
def run(command, **kwargs):
buffer_output = kwargs.pop('buffer_output', BUFFER_OUTPUT)
quiet = kwargs.pop('quiet', QUIET)
verbose = not quiet
if buffer_output:
assert 'stdout' not in kwargs and 'stderr' not in kwargs, kwargs
kwargs['stderr'] = subprocess.STDOUT
......@@ -192,7 +194,8 @@ def run(command, **kwargs):
kill(popen)
assert not err
with lock:
if out:
failed = bool(result)
if out and (failed or verbose):
out = out.strip().decode('utf-8', 'ignore')
if out:
out = ' ' + out.replace('\n', '\n ')
......
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