summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2013-03-22 17:41:10 +1300
committerRobert Collins <robertc@robertcollins.net>2013-03-22 17:41:10 +1300
commitd773e3c7101528038ef618236f4f55d8c04eabb4 (patch)
treeebf71f82d9ad2d03a990e8e8e1573ec2c9736bf4
parent4a950295a68c56a26a8109f8bdd7657e9d70903c (diff)
downloadtestrepository-d773e3c7101528038ef618236f4f55d8c04eabb4.tar.gz
Migrate to new streamresult concurrent test suite API.
-rw-r--r--testrepository/commands/load.py15
-rw-r--r--testrepository/tests/commands/test_load.py14
-rw-r--r--testrepository/ui/cli.py7
3 files changed, 9 insertions, 27 deletions
diff --git a/testrepository/commands/load.py b/testrepository/commands/load.py
index c762ce0..c2fe2bf 100644
--- a/testrepository/commands/load.py
+++ b/testrepository/commands/load.py
@@ -23,7 +23,6 @@ v2_avail = try_import('subunit.ByteStreamToStreamResult')
import subunit.test_results
import testtools
-from testtools import ConcurrentTestSuite, MultiTestResult, Tagger
from testrepository.arguments.path import ExistingPathArgument
from testrepository.commands import Command
@@ -31,14 +30,6 @@ from testrepository.repository import RepositoryNotFound
from testrepository.testcommand import TestCommand
-def _wrap_result(result, thread_number):
- worker_id = 'worker-%s' % thread_number
- tags_to_add = set([worker_id])
- tags_to_remove = set()
- return subunit.test_results.AutoTimingTestResultDecorator(
- Tagger(result, tags_to_add, tags_to_remove))
-
-
class load(Command):
"""Load a subunit stream into a repository.
@@ -88,8 +79,8 @@ class load(Command):
else:
cases = lambda:self.ui.iter_streams('subunit')
def make_tests(suite):
- streams = list(suite)[0]
- for pos, stream in enumerate(streams()):
+ streams = list(suite)
+ for pos, stream in enumerate(streams):
if v2_avail:
# Calls StreamResult API.
case = subunit.ByteStreamToStreamResult(
@@ -107,7 +98,7 @@ class load(Command):
lambda result:testtools.StreamTagger(
[result], add=['worker-%d' % pos]))
yield (case, str(pos))
- case = testtools.ConcurrentStreamTestSuite(cases, make_tests)
+ case = testtools.ConcurrentStreamTestSuite(lambda: list(make_tests(cases())))
# One unmodified copy of the stream to repository storage
inserter = repo.get_inserter(partial=self.ui.options.partial)
# One copy of the stream to the UI layer after performing global
diff --git a/testrepository/tests/commands/test_load.py b/testrepository/tests/commands/test_load.py
index 5fd7f3d..2b1f90e 100644
--- a/testrepository/tests/commands/test_load.py
+++ b/testrepository/tests/commands/test_load.py
@@ -266,20 +266,6 @@ class TestCommandLoad(ResourcedTestCase):
[('summary', True, 1, None, 2.0, None, [('id', 0, None)])],
ui.outputs[1:])
- def test_load__wrap_result_inserts_worker_id_tag(self):
- # The load command uses a result wrapper that tags each test with the
- # ID of the worker that executed the test.
- log = []
- result = load._wrap_result(LoggingResult(log), 99)
- result.startTestRun()
- result.startTest(self)
- result.addUnexpectedSuccess(self)
- result.stopTest(self)
- result.stopTestRun()
- # Even though no tag data was provided above, the test has been tagged
- # with the worker ID.
- self.assertIn(('tags', set(['worker-99']), set([])), log)
-
def test_load_second_run(self):
# If there's a previous run in the database, then show information
# about the high level differences in the test run: how many more
diff --git a/testrepository/ui/cli.py b/testrepository/ui/cli.py
index 65f7413..b0de823 100644
--- a/testrepository/ui/cli.py
+++ b/testrepository/ui/cli.py
@@ -80,9 +80,14 @@ class UI(ui.AbstractUI):
def make_result(self, get_id, test_command, previous_run=None):
if getattr(self.options, 'subunit', False):
- # By pass user transforms - just forward it all.
+ # By pass user transforms - just forward it all and interpret
+ # everything as success.
result = ExtendedToStreamDecorator(StreamToExtendedDecorator(
subunit.TestProtocolClient(self._stdout)))
+ summary = testtools.StreamSummary()
+ summary.startTestRun()
+ summary.stopTestRun()
+ return result, summary
else:
output = CLITestResult(self, get_id, self._stdout, previous_run)
# Apply user defined transforms.