diff --git a/tools/pretty_tox.sh b/tools/pretty_tox.sh index ddbf2220c3..137f7df3f6 100755 --- a/tools/pretty_tox.sh +++ b/tools/pretty_tox.sh @@ -3,4 +3,4 @@ set -o pipefail TESTRARGS=$1 -python -m nova.openstack.common.lockutils python setup.py testr --slowest --testr-args="--subunit $TESTRARGS" | $(dirname $0)/subunit-trace.py --no-failure-debug -f +python -m nova.openstack.common.lockutils python setup.py testr --slowest --testr-args="--subunit $TESTRARGS" | $(dirname $0)/subunit-trace.py -f diff --git a/tools/subunit-trace.py b/tools/subunit-trace.py index 8ad59bbabb..9501b1e1ab 100755 --- a/tools/subunit-trace.py +++ b/tools/subunit-trace.py @@ -20,6 +20,7 @@ import argparse import functools +import os import re import sys @@ -152,7 +153,7 @@ def print_attachments(stream, test, all_channels=False): stream.write(" %s\n" % line) -def show_outcome(stream, test, print_failures=False): +def show_outcome(stream, test, print_failures=False, failonly=False): global RESULTS status = test['status'] # TODO(sdague): ask lifeless why on this? @@ -171,24 +172,25 @@ def show_outcome(stream, test, print_failures=False): if name == 'process-returncode': return - if status == 'success': - stream.write('{%s} %s [%s] ... ok\n' % ( - worker, name, duration)) - print_attachments(stream, test) - elif status == 'fail': + if status == 'fail': FAILS.append(test) stream.write('{%s} %s [%s] ... FAILED\n' % ( worker, name, duration)) if not print_failures: print_attachments(stream, test, all_channels=True) - elif status == 'skip': - stream.write('{%s} %s ... SKIPPED: %s\n' % ( - worker, name, test['details']['reason'].as_text())) - else: - stream.write('{%s} %s [%s] ... %s\n' % ( - worker, name, duration, test['status'])) - if not print_failures: - print_attachments(stream, test, all_channels=True) + elif not failonly: + if status == 'success': + stream.write('{%s} %s [%s] ... ok\n' % ( + worker, name, duration)) + print_attachments(stream, test) + elif status == 'skip': + stream.write('{%s} %s ... SKIPPED: %s\n' % ( + worker, name, test['details']['reason'].as_text())) + else: + stream.write('{%s} %s [%s] ... %s\n' % ( + worker, name, duration, test['status'])) + if not print_failures: + print_attachments(stream, test, all_channels=True) stream.flush() @@ -267,6 +269,11 @@ def parse_args(): parser.add_argument('--fails', '-f', action='store_true', dest='post_fails', help='Print failure debug ' 'information after the stream is proccesed') + parser.add_argument('--failonly', action='store_true', + dest='failonly', help="Don't print success items", + default=( + os.environ.get('TRACE_FAILONLY', False) + is not False)) return parser.parse_args() @@ -277,7 +284,9 @@ def main(): starts = Starts(sys.stdout) outcomes = testtools.StreamToDict( functools.partial(show_outcome, sys.stdout, - print_failures=args.print_failures)) + print_failures=args.print_failures, + failonly=args.failonly + )) summary = testtools.StreamSummary() result = testtools.CopyStreamResult([starts, outcomes, summary]) result.startTestRun() diff --git a/tox.ini b/tox.ini index 954d3e09ad..46e560799c 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,8 @@ deps = -r{toxinidir}/requirements.txt commands = find . -type f -name "*.pyc" -delete bash tools/pretty_tox.sh '{posargs}' +# there is also secret magic in pretty_tox.sh which lets you run in a fail only +# mode. To do this define the TRACE_FAILONLY environmental variable. [tox:jenkins] downloadcache = ~/cache/pip