Rev 78: Implement a crude --progress for 'testr load'. in http://bzr.arbash-meinel.com/branches/bzr/other/testrepository
John Arbash Meinel
john at arbash-meinel.com
Tue Jan 19 17:14:51 GMT 2010
At http://bzr.arbash-meinel.com/branches/bzr/other/testrepository
------------------------------------------------------------
revno: 78
revision-id: john at arbash-meinel.com-20100119171418-ltm2nt9o9pu28cf4
parent: robertc at robertcollins.net-20100116000145-ge3edeoj41j0fbrk
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: testrepository
timestamp: Tue 2010-01-19 11:14:18 -0600
message:
Implement a crude --progress for 'testr load'.
We already had a few result classes, this just adds one.
Also, it is a bit unfortunate that inserter.stopTestRun() has
a return value, as none of the other result classes do, and
MultiTestResult certainly doesn't return it.
I don't really understand why Robert called one startTestRun
and stopTestRun but didn't call all of them.
-------------- next part --------------
=== modified file '.bzrignore'
--- a/.bzrignore 2009-12-24 09:46:40 +0000
+++ b/.bzrignore 2010-01-19 17:14:18 +0000
@@ -3,3 +3,4 @@
test.xml
build
.testrepository
+./tags
=== modified file 'testrepository/commands/load.py'
--- a/testrepository/commands/load.py 2010-01-10 08:52:00 +0000
+++ b/testrepository/commands/load.py 2010-01-19 17:14:18 +0000
@@ -15,12 +15,25 @@
"""Load data into a repository."""
from cStringIO import StringIO
+import optparse
import subunit.test_results
from testtools import MultiTestResult, TestResult
from testrepository.commands import Command
+
+def get_bzrlib_result():
+ import sys
+ import unittest
+ from bzrlib import ui, tests
+ ui.ui_factory = ui.make_ui_for_terminal(None, sys.stdout, sys.stderr)
+ # TODO: We should probably suppress stream.writeln instead...
+ stream = unittest._WritelnDecorator(sys.stderr)
+ result = tests.TextTestResult(stream, descriptions=0, verbosity=1)
+ return result
+
+
class load(Command):
"""Load a subunit stream into a repository.
@@ -30,6 +43,9 @@
input_streams = ['subunit+']
+ options = [optparse.Option("--progress", "-p", action="store_true",
+ default=False, help="Output progress information while loading.")]
+
def run(self):
path = self.ui.here
repo = self.repository_factory.open(path)
@@ -42,11 +58,17 @@
filtered = subunit.test_results.TestResultFilter(output_stream,
filter_skip=True)
case = subunit.ProtocolTestCase(stream)
- inserter.startTestRun()
+ results = [inserter, evaluator, filtered]
+ if self.ui.options.progress:
+ results.append(get_bzrlib_result())
+ combined_result = MultiTestResult(*results)
+ combined_result.startTestRun()
try:
- case.run(MultiTestResult(inserter, evaluator, filtered))
+ case.run(combined_result)
finally:
run_id = inserter.stopTestRun()
+ for res in results[1:]:
+ res.stopTestRun()
failed = failed or not evaluator.wasSuccessful()
self.output_run(run_id, output, evaluator)
if failed:
More information about the bazaar-commits
mailing list