Bring back colorizer again with error results.

This was actually a pretty simple fix. When I switched the base
test result class to testtools I lost the methods that were
printing out the errors at the end. This adds the (colorized!)
methods so errors print successfully.

fixes bug 1159116

Change-Id: Ib09d7e18ddf27015ff735a30137421d865382359
This commit is contained in:
Vishvananda Ishaya
2013-03-26 12:17:39 -07:00
parent 2900258d5e
commit 89c501ec13
2 changed files with 18 additions and 2 deletions

View File

@@ -129,7 +129,7 @@ function run_tests {
if [ $coverage -eq 1 ]; then
TESTRTESTS="$TESTRTESTS --coverage"
else
TESTRTESTS="$TESTRTESTS --slowest"
TESTRTESTS="$TESTRTESTS"
fi
# Just run the test suites in current environment
@@ -137,7 +137,7 @@ function run_tests {
testrargs=`echo "$testrargs" | sed -e's/^\s*\(.*\)\s*$/\1/'`
TESTRTESTS="$TESTRTESTS --testr-args='--subunit $testropts $testrargs'"
echo "Running \`${wrapper} $TESTRTESTS\`"
bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit2pyunit"
bash -c "${wrapper} $TESTRTESTS | ${wrapper} tools/colorizer.py"
RESULT=$?
set -e

View File

@@ -302,6 +302,22 @@ class NovaTestResult(testtools.TestResult):
self._writeElapsedTime(elapsed)
self.stream.writeln()
def printErrors(self):
if self.showAll:
self.stream.writeln()
self.printErrorList('ERROR', self.errors)
self.printErrorList('FAIL', self.failures)
def printErrorList(self, flavor, errors):
for test, err in errors:
self.colorizer.write("=" * 70, 'red')
self.stream.writeln()
self.colorizer.write(flavor, 'red')
self.stream.writeln(": %s" % test.id())
self.colorizer.write("-" * 70, 'red')
self.stream.writeln()
self.stream.writeln("%s" % err)
test = subunit.ProtocolTestCase(sys.stdin, passthrough=None)