Rev 4172: (robertc) Add subunit reporting into the core test suite facilities. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Mar 20 04:27:33 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4172
revision-id: pqm at pqm.ubuntu.com-20090320042728-fx1fhqsjmd2svpr3
parent: pqm at pqm.ubuntu.com-20090320025535-havsm27xdtwnpl42
parent: robertc at robertcollins.net-20090320034235-6z0o0jf47e110jse
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-03-20 04:27:28 +0000
message:
(robertc) Add subunit reporting into the core test suite facilities.
(Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_selftest.py test_selftest.py-20060123024542-01c5f1bbcb596d78
------------------------------------------------------------
revno: 4165.1.2
revision-id: robertc at robertcollins.net-20090320034235-6z0o0jf47e110jse
parent: robertc at robertcollins.net-20090320010458-v8ervol4dpjxqx48
committer: Robert Collins <robertc at robertcollins.net>
branch nick: subunit
timestamp: Fri 2009-03-20 14:42:35 +1100
message:
Make a clear error when attempting to use subunit and it is not available.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
------------------------------------------------------------
revno: 4165.1.1
revision-id: robertc at robertcollins.net-20090320010458-v8ervol4dpjxqx48
parent: pqm at pqm.ubuntu.com-20090319035632-3o6ewx7kwnk42b63
committer: Robert Collins <robertc at robertcollins.net>
branch nick: subunit
timestamp: Fri 2009-03-20 12:04:58 +1100
message:
Add builtin subunit support.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_selftest.py test_selftest.py-20060123024542-01c5f1bbcb596d78
=== modified file 'NEWS'
--- a/NEWS 2009-03-19 14:41:41 +0000
+++ b/NEWS 2009-03-20 04:27:28 +0000
@@ -148,7 +148,11 @@
* Removed ``InterRemoteToOther``, ``InterOtherToRemote`` and
``InterPackToRemotePack`` classes, as they are now unnecessary.
(Andrew Bennetts)
-
+
+* ``bzr selftest`` now accepts ``--subunit`` to run in subunit output
+ mode. Requires ``lp:subunit`` installed to work, but is not a hard
+ dependency. (Robert Collins)
+
* ``_walk_to_common_revisions`` will now batch up at least 50
revisions before calling ``get_parent_map`` on the target,
regardless of ``InterRepository``.
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-03-17 22:22:57 +0000
+++ b/bzrlib/builtins.py 2009-03-20 03:42:35 +0000
@@ -3143,6 +3143,8 @@
short_name='x',
help='Exclude tests that match this regular'
' expression.'),
+ Option('subunit',
+ help='Output test progress via subunit.'),
Option('strict', help='Fail on missing dependencies or '
'known failures.'),
Option('load-list', type=str, argname='TESTLISTFILE',
@@ -3165,7 +3167,7 @@
lsprof_timed=None, cache_dir=None,
first=False, list_only=False,
randomize=None, exclude=None, strict=False,
- load_list=None, debugflag=None, starting_with=None):
+ load_list=None, debugflag=None, starting_with=None, subunit=False):
from bzrlib.tests import selftest
import bzrlib.benchmarks as benchmarks
from bzrlib.benchmarks import tree_creator
@@ -3187,6 +3189,13 @@
pattern = '|'.join(testspecs_list)
else:
pattern = ".*"
+ if subunit:
+ try:
+ from bzrlib.tests import SubUnitBzrRunner
+ except ImportError:
+ raise errors.BzrCommandError("subunit not available. subunit "
+ "needs to be installed to use --subunit.")
+ self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
if benchmark:
test_suite_factory = benchmarks.test_suite
# Unless user explicitly asks for quiet, be verbose in benchmarks
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2009-03-18 18:28:37 +0000
+++ b/bzrlib/tests/__init__.py 2009-03-20 04:27:28 +0000
@@ -3526,3 +3526,31 @@
return 'case-insensitive filesystem'
CaseInsensitiveFilesystemFeature = _CaseInsensitiveFilesystemFeature()
+
+
+class _SubUnitFeature(Feature):
+ """Check if subunit is available."""
+
+ def _probe(self):
+ try:
+ import subunit
+ return True
+ except ImportError:
+ return False
+
+ def feature_name(self):
+ return 'subunit'
+
+SubUnitFeature = _SubUnitFeature()
+# Only define SubUnitBzrRunner if subunit is available.
+try:
+ from subunit import TestProtocolClient
+ class SubUnitBzrRunner(TextTestRunner):
+ def run(self, test):
+ # undo out claim for testing which looks like a test start to subunit
+ self.stream.write("success: %s\n" % (osutils.realpath(sys.argv[0]),))
+ result = TestProtocolClient(self.stream)
+ test.run(result)
+ return result
+except ImportError:
+ pass
=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py 2009-01-17 01:30:58 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py 2009-03-20 01:04:58 +0000
@@ -16,10 +16,12 @@
"""UI tests for the test framework."""
+from cStringIO import StringIO
import os
import re
import signal
import sys
+import unittest
import bzrlib
from bzrlib import (
@@ -27,6 +29,7 @@
)
from bzrlib.errors import ParamikoNotPresent
from bzrlib.tests import (
+ SubUnitFeature,
TestCase,
TestCaseInTempDir,
TestCaseWithMemoryTransport,
@@ -88,6 +91,21 @@
TestOptions.current_test = None
TestCaseWithMemoryTransport.TEST_ROOT = old_root
+ def test_subunit(self):
+ """Passing --subunit results in subunit output."""
+ self.requireFeature(SubUnitFeature)
+ from subunit import ProtocolTestCase
+ stdout = self.run_bzr(
+ 'selftest --subunit --no-plugins '
+ 'tests.test_selftest.SelftestTests.test_import_tests')[0]
+ stream = StringIO(str(stdout))
+ test = ProtocolTestCase(stream)
+ result = unittest.TestResult()
+ test.run(result)
+ # 1 to deal with the 'test:' noise at the start, and 1 for the one we
+ # ran.
+ self.assertEqual(2, result.testsRun)
+
class TestRunBzr(ExternalBase):
More information about the bazaar-commits
mailing list