Use subunit-trace to enable output during unit test runs

This commit adds the pretty_tox.sh script and the usage of
subunit-trace to the cinder unit test jobs. This also updates the
run_tests.sh script to use subunit-trace so it'll have consistent
output formatting with the tox job.

Change-Id: I8ceafb476dc488b388c7f63501ef48128d8383d2
This commit is contained in:
Matthew Treinish 2015-02-20 20:35:01 -05:00
parent 5e05d97231
commit 456db81765
4 changed files with 19 additions and 9 deletions

View File

@ -150,14 +150,7 @@ function run_tests {
${wrapper} python setup.py egg_info
fi
echo "Running \`${wrapper} $TESTRTESTS\`"
if ${wrapper} which subunit-2to1 2>&1 > /dev/null
then
# subunit-2to1 is present, testr subunit stream should be in version 2
# format. Convert to version one before colorizing.
bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py"
else
bash -c "${wrapper} $TESTRTESTS | ${wrapper} tools/colorizer.py"
fi
bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit-trace"
RESULT=$?
set -e

View File

@ -17,3 +17,4 @@ python-subunit>=0.0.18
testtools>=0.9.36,!=1.2.0
testrepository>=0.0.18
oslosphinx>=2.2.0 # Apache-2.0
tempest-lib>=0.2.0

16
tools/pretty_tox.sh Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -o pipefail
TESTRARGS=$1
# --until-failure is not compatible with --subunit see:
#
# https://bugs.launchpad.net/testrepository/+bug/1411804
#
# this work around exists until that is addressed
if [[ "$TESTARGS" =~ "until-failure" ]]; then
python setup.py test --no-parallel --slowest --testr-args="$TESTRARGS"
else
python setup.py test --no-parallel --slowest --testr-args="--subunit $TESTRARGS" | subunit-trace -f
fi

View File

@ -14,7 +14,7 @@ install_command = pip install {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
python setup.py testr --slowest --testr-args='--concurrency 1 {posargs}'
bash tools/pretty_tox.sh '{posargs}'
whitelist_externals = bash
[tox:jenkins]