Fixes from getting testrepository running with v2.

This commit is contained in:
Robert Collins
2013-03-06 23:16:03 +13:00
parent 36de6f4f75
commit 2c84805617
4 changed files with 75 additions and 21 deletions

View File

@@ -19,7 +19,9 @@
from optparse import OptionParser
import sys
from testtools import StreamToExtendedDecorator, StreamResultRouter
from testtools import (
CopyStreamResult, StreamToExtendedDecorator, StreamResultRouter,
StreamSummary)
from subunit import ByteStreamToStreamResult
from subunit.filters import run_tests_from_stream
@@ -33,23 +35,24 @@ parser = OptionParser(description=__doc__)
parser.add_option("--times", action="store_true",
help="list the time each test took (requires a timestamped stream)",
default=False)
parser.add_option("--exists", action="store_true",
help="list tests that are reported as existing (as well as ran)",
default=False)
parser.add_option("--no-passthrough", action="store_true",
help="Hide all non subunit input.", default=False, dest="no_passthrough")
(options, args) = parser.parse_args()
test = ByteStreamToStreamResult(sys.stdin, non_subunit_name="stdout")
printer = TestIdPrintingResult(sys.stdout, options.times)
result = StreamToExtendedDecorator(printer)
result = TestIdPrintingResult(sys.stdout, options.times, options.exists)
if not options.no_passthrough:
orig_result = result
result = StreamResultRouter(result)
cat = CatFiles(sys.stdout)
result.map(cat, 'test_id', test_id=None)
else:
orig_result = result
orig_result.startTestRun()
summary = StreamSummary()
result = CopyStreamResult([result, summary])
result.startTestRun()
test.run(result)
orig_result.stopTestRun()
if printer.wasSuccessful():
result.stopTestRun()
if summary.wasSuccessful():
exit_code = 0
else:
exit_code = 1