Rev 2485: Add a --load parameter to ./bzr selftest, which causes selftest in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/selftest_only
John Arbash Meinel
john at arbash-meinel.com
Wed May 9 04:21:44 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/selftest_only
------------------------------------------------------------
revno: 2485
revision-id: john at arbash-meinel.com-20070509032110-dop1a5diw6a0jifu
parent: pqm at pqm.ubuntu.com-20070508203256-wcxwdphd1y2psezh
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: selftest_only
timestamp: Tue 2007-05-08 22:21:10 -0500
message:
Add a --load parameter to ./bzr selftest, which causes selftest
to only load those modules. This makes loading and running a subset of
the test suite much faster.
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_selftest.py test_selftest.py-20060123024542-01c5f1bbcb596d78
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-05-02 14:54:20 +0000
+++ b/bzrlib/builtins.py 2007-05-09 03:21:10 +0000
@@ -2428,6 +2428,10 @@
),
Option('numbered-dirs',
help='use numbered dirs for TestCaseInTempDir'),
+ ListOption('load', type=str,
+ help='Load only tests from the specified'
+ ' module. This can be specified'
+ ' multiple times.'),
Option('list-only',
help='list the tests instead of running them'),
Option('randomize', type=str, argname="SEED",
@@ -2444,9 +2448,9 @@
keep_output=False, transport=None, benchmark=None,
lsprof_timed=None, cache_dir=None, clean_output=False,
first=False, numbered_dirs=None, list_only=False,
- randomize=None, exclude=None):
+ randomize=None, exclude=None, load=None):
import bzrlib.ui
- from bzrlib.tests import selftest
+ from bzrlib.tests import selftest, TestLoader
import bzrlib.benchmarks as benchmarks
from bzrlib.benchmarks import tree_creator
@@ -2478,6 +2482,11 @@
if verbose is None:
verbose = False
benchfile = None
+ if load:
+ def load_just_test_suite():
+ loader = TestLoader()
+ return loader.loadTestsFromModuleNames(load)
+ test_suite_factory = load_just_test_suite
try:
result = selftest(verbose=verbose,
pattern=pattern,
=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py 2007-05-04 10:13:17 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py 2007-05-09 03:21:10 +0000
@@ -579,3 +579,41 @@
out_rand2.splitlines(), 2)
self.assertEqual(tests_rand, tests_rand2)
+
+class TestSelftestLoad(TestCase):
+
+ def test_load_and_list(self):
+ # Check that --load can specify just one module to load.
+ out, err = self.run_bzr('selftest', '--list-only', '--load',
+ 'bzrlib.tests.blackbox.test_selftest'
+ )
+ tests = TestSelftestListOnly._parse_test_list(out.splitlines())[1]
+ self.assertNotEqual([], tests)
+ # Only tests in blackbox.test_selftest should be loaded.
+ for test in tests:
+ self.assertStartsWith(test,
+ 'bzrlib.tests.blackbox.test_selftest.')
+
+ def test_load_list_and_restrict(self):
+ out, err = self.run_bzr('selftest', '--list-only', '--load',
+ 'bzrlib.tests.blackbox.test_selftest',
+ 'load_list.*restrict',
+ )
+ # Passing standard restrictions should further reduce the number of
+ # tests run.
+ tests = TestSelftestListOnly._parse_test_list(out.splitlines())[1]
+ self.assertEqual(['bzrlib.tests.blackbox.test_selftest'
+ '.TestSelftestLoad.test_load_list_and_restrict'],
+ tests)
+
+ def test_load_multiple(self):
+ out, err = self.run_bzr('selftest', '--list-only', '--load',
+ 'bzrlib.tests.blackbox.test_selftest',
+ '--load', 'bzrlib.tests.test_selftest',
+ )
+ tests = TestSelftestListOnly._parse_test_list(out.splitlines())[1]
+ self.assertNotEqual([], tests)
+ for test in tests:
+ self.assertContainsRe(test,
+ r'bzrlib\.tests\.'
+ r'(blackbox\.)?test_selftest\.')
More information about the bazaar-commits
mailing list