Rev 3201: Add '--load-list' option to selftest. in file:///v/home/vila/src/bzr/experimental/selftest/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Jan 21 10:51:08 GMT 2008


At file:///v/home/vila/src/bzr/experimental/selftest/

------------------------------------------------------------
revno: 3201
revision-id:v.ladeuil+lp at free.fr-20080121105102-j5q7nmtbqw3vbrle
parent: v.ladeuil+lp at free.fr-20080121101622-pj98frqla59g5olb
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: selftest
timestamp: Mon 2008-01-21 11:51:02 +0100
message:
  Add '--load-list' option to selftest.
  
  * bzrlib/tests/test_selftest.py:
  (TestTestIdListFilter.test_test_suite): Delete the plugin test, it
  is indeed fragile.
  
  * bzrlib/tests/blackbox/test_selftest.py:
  (TestSelftestWithIdList): Test the --load-list-option.
  
  * bzrlib/tests/__init__.py:
  (selftest): Add a --load-list option.
  
  * bzrlib/builtins.py:
  (cmd_selftest): Add a --load-list option.
modified:
  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
  bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-01-16 12:47:54 +0000
+++ b/bzrlib/builtins.py	2008-01-21 10:51:02 +0000
@@ -2601,6 +2601,8 @@
                      Option('coverage', type=str, argname="DIRECTORY",
                             help='Generate line coverage report in this '
                                  'directory.'),
+                     Option('load-list', type=str, argname='TESTLISTFILE',
+                            help='Load a test id list from a text file.'),
                      ]
     encoding_type = 'replace'
 
@@ -2608,7 +2610,8 @@
             transport=None, benchmark=None,
             lsprof_timed=None, cache_dir=None,
             first=False, list_only=False,
-            randomize=None, exclude=None, strict=False, coverage=None):
+            randomize=None, exclude=None, strict=False, coverage=None,
+            load_list=None):
         import bzrlib.ui
         from bzrlib.tests import selftest
         import bzrlib.benchmarks as benchmarks
@@ -2651,6 +2654,7 @@
                               exclude_pattern=exclude,
                               strict=strict,
                               coverage_dir=coverage,
+                              load_list=load_list,
                               )
         finally:
             if benchfile is not None:

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2008-01-21 10:16:22 +0000
+++ b/bzrlib/tests/__init__.py	2008-01-21 10:51:02 +0000
@@ -2523,6 +2523,7 @@
              exclude_pattern=None,
              strict=False,
              coverage_dir=None,
+             load_list=None,
              ):
     """Run the whole test suite under the enhanced runner"""
     # XXX: Very ugly way to do this...
@@ -2537,8 +2538,12 @@
     old_transport = default_transport
     default_transport = transport
     try:
+        if load_list is None:
+            keep_only = None
+        else:
+            keep_only = load_test_id_list(load_list)
         if test_suite_factory is None:
-            suite = test_suite()
+            suite = test_suite(keep_only)
         else:
             suite = test_suite_factory()
         return run_suite(suite, 'testbzr', verbose=verbose, pattern=pattern,
@@ -2866,8 +2871,6 @@
                 if keep_only is not None:
                     plugin_suite = id_filter.for_module_and_below(
                         plugin.module.__name__, plugin_suite)
-                if name == 'multiparent':
-                    import pdb; pdb.set_trace()
                 suite.addTest(plugin_suite)
         if default_encoding != sys.getdefaultencoding():
             bzrlib.trace.warning(

=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py	2007-12-24 10:31:24 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py	2008-01-21 10:51:02 +0000
@@ -558,3 +558,20 @@
             out_rand2.splitlines(), 2)
         self.assertEqual(tests_rand, tests_rand2)
 
+
+class TestSelftestWithIdList(TestCaseInTempDir):
+
+    def test_load_list(self):
+        # We don't want to call selftest for the whole suite, so we start with
+        # a reduced list.
+        test_list_fname = 'test.list'
+        fl = open(test_list_fname, 'wt')
+        fl.write('%s\n' % self.id())
+        fl.close()
+        out, err = self.run_bzr(
+            ['selftest', '--load-list', test_list_fname, '--list'])
+        self.assertContainsRe(out, "Listed 1 test in")
+
+    def test_load_unknown(self):
+        out, err = self.run_bzr('selftest --load-list I_do_not_exist ',
+                                retcode=3)

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2008-01-21 10:16:22 +0000
+++ b/bzrlib/tests/test_selftest.py	2008-01-21 10:51:02 +0000
@@ -1984,13 +1984,10 @@
             'bzrlib.tests.blackbox.test_branch.TestBranch.test_branch',
             # MODULES_TO_DOCTEST
             'bzrlib.timestamp.format_highres_date',
-            # plugins (launchpad is included with core, but this may be
-            # fragile)
-            'bzrlib.plugins.launchpad.test_register.TestBranchRegistration'
-            '.test_mock_bug_branch_link',
+            # plugins can't be tested that way since selftest may be run with
+            # --no-plugins
             ]
         suite = tests.test_suite(test_list)
-        self.assertEquals(len(test_list), suite.countTestCases())
         self.assertEquals(test_list, self._test_ids(suite))
 
 



More information about the bazaar-commits mailing list