Rev 3343: Fixed as per John's review. Also added a NEWS entry. in file:///v/home/vila/src/bzr/experimental/faster-selftest/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Apr 30 22:41:24 BST 2008


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

------------------------------------------------------------
revno: 3343
revision-id: v.ladeuil+lp at free.fr-20080430214120-fa7nx8d4m0ui8gdw
parent: v.ladeuil+lp at free.fr-20080430213235-tgn24ahe6dwwyy7j
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: selftest-starts-with
timestamp: Wed 2008-04-30 23:41:20 +0200
message:
  Fixed as per John's review. Also added a NEWS entry.
  
  * bzrlib/tests/blackbox/test_selftest.py:
  (TestSelftestStartingWith.test_starting_with): Harden the test by
  checking that the test id is really listed.
  
  * bzrlib/tests/__init__.py:
  (test_suite): Define interesting_module more precisely. Give a
  better explanation for not reporting unkwon tests when both
  keep_only and starting_with are used together.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/blackbox/test_selftest.py test_selftest.py-20060123024542-01c5f1bbcb596d78
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-04-30 20:09:39 +0000
+++ b/NEWS	2008-04-30 21:41:20 +0000
@@ -83,6 +83,11 @@
       make it easy to identify which test spawned a thread with an unhandled
       exception. (Andrew Bennetts)
 
+    * selftest now accepts --starting-with <id> to load only the tests whose id
+      starts with the one specified. This greatly speeds up running the test
+      suite on a limited set of tests and can be used to run the tests for a
+      single module, a single class or even a single test.  (Vincent Ladeuil)
+
     * The test suite modules have been modified to define load_tests() instead
       of test_suite(). That speeds up selective loading (via --load-list)
       significantly and provides many examples on how to migrate (grep for

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2008-04-23 20:47:51 +0000
+++ b/bzrlib/tests/__init__.py	2008-04-30 21:41:20 +0000
@@ -2814,11 +2814,21 @@
         # We take precedence over keep_only because *at loading time* using
         # both options means we will load less tests for the same final result.
         loader = TestUtil.FilteredByModuleTestLoader(starting_with.startswith)
+        def interesting_module(name):
+            return name.startswith(starting_with)
+
     elif keep_only is not None:
         id_filter = TestIdList(keep_only)
         loader = TestUtil.FilteredByModuleTestLoader(id_filter.refers_to)
+        def interesting_module(name):
+            return id_filter.refers_to(name)
+
     else:
         loader = TestUtil.TestLoader()
+        def interesting_module(name):
+            # No filtering, all modules are interesting
+            return True
+
     suite = loader.suiteClass()
 
     # modules building their suite with loadTestsFromModuleNames
@@ -2839,14 +2849,6 @@
         'bzrlib.version_info_formats.format_custom',
         ]
 
-    def interesting_module(name):
-        if starting_with is not None:
-            return name.startswith(starting_with)
-        elif keep_only is not None:
-            return id_filter.refers_to(name)
-        else:
-            return True
-
     for mod in modules_to_doctest:
         if not interesting_module(mod):
             # No tests to keep here, move along
@@ -2887,10 +2889,13 @@
         # Do some sanity checks on the id_list filtering
         not_found, duplicates = suite_matches_id_list(suite, keep_only)
         if starting_with is not None:
-            # No need to annoy the tester with tests not found since when both
-            # options are used *there will be* tests excluded from the list.
+            # The tester has used both keep_only and starting_with, so he is
+            # already aware that some tests are excluded from the list, there
+            # is no need to tell him which.
             pass
         else:
+            # Some tests mentioned in the list are not in the test suite. The
+            # list may be out of date, report to the tester.
             for id in not_found:
                 bzrlib.trace.warning('"%s" not found in the test suite', id)
         for id in duplicates:

=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py	2008-04-23 20:47:51 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py	2008-04-30 21:41:20 +0000
@@ -583,4 +583,5 @@
         out, err = self.run_bzr(
             ['selftest', '--starting-with', self.id(), '--list'])
         self.assertContainsRe(out, "Listed 1 test in")
+        self.assertContainsRe(out, self.id())
 



More information about the bazaar-commits mailing list