Commit ca9c3b8c authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #948 from gevent/issue926

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