Rev 3344: Fixed as per Martin and John reviews. Also fix a bug. in file:///v/home/vila/src/bzr/experimental/faster-selftest/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue May 6 21:22:07 BST 2008


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

------------------------------------------------------------
revno: 3344
revision-id: v.ladeuil+lp at free.fr-20080506202159-36euxn0hhckl1eqx
parent: v.ladeuil+lp at free.fr-20080430214120-fa7nx8d4m0ui8gdw
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: selftest-starts-with
timestamp: Tue 2008-05-06 22:21:59 +0200
message:
  Fixed as per Martin and John reviews. Also fix a bug.
  
  * bzrlib/tests/test_selftest.py:
  (TestFilteredByNameStartTestLoader): Add a test for 
  
  * bzrlib/tests/__init__.py:
  (test_suite.interesting_module): The module may contains tests
  that starts with the specified string even if the module name
  doesn't.
  
  * doc/developers/HACKING.txt:
  We have doubled the number of tests in one year 8-)
  Add some explanations about --load-list and --starting-with.
  
  * bzrlib/builtins.py:
  (cmd_selftest): Add '-s' for --starting-with.
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
  doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-04-30 21:32:35 +0000
+++ b/bzrlib/builtins.py	2008-05-06 20:21:59 +0000
@@ -2660,6 +2660,7 @@
                      Option('load-list', type=str, argname='TESTLISTFILE',
                             help='Load a test id list from a text file.'),
                      Option('starting-with', type=str, argname='TESTID',
+                            short_name='s',
                             help='Load only the tests starting with TESTID.'),
                      ]
     encoding_type = 'replace'

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2008-04-30 21:41:20 +0000
+++ b/bzrlib/tests/__init__.py	2008-05-06 20:21:59 +0000
@@ -2813,9 +2813,14 @@
     if starting_with is not None:
         # 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)
+            return (
+                # Either the module name starts with the specified string
+                name.startswith(starting_with)
+                # or it may contain tests starting with the specified string
+                or starting_with.startswith(name)
+                )
+        loader = TestUtil.FilteredByModuleTestLoader(interesting_module)
 
     elif keep_only is not None:
         id_filter = TestIdList(keep_only)

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2008-04-30 21:32:35 +0000
+++ b/bzrlib/tests/test_selftest.py	2008-05-06 20:21:59 +0000
@@ -1815,8 +1815,8 @@
              'TestSelftestFiltering.test_filter_suite_by_id_list'])
 
     def test_filter_suite_by_id_startswith(self):
-        # By design this test may fail if another test is added whose a name
-        # also begins with the start value used.
+        # By design this test may fail if another test is added whose name also
+        # begins with the start value used.
         klass = 'bzrlib.tests.test_selftest.TestSelftestFiltering.'
         start = klass + 'test_filter_suite_by_id_starts'
         test_list = [klass + 'test_filter_suite_by_id_startswith']
@@ -2108,12 +2108,21 @@
 class TestFilteredByNameStartTestLoader(tests.TestCase):
 
     def _create_loader(self, name_start):
-        loader = TestUtil.FilteredByModuleTestLoader(name_start.startswith)
+        def needs_module(name):
+            return name.startswith(name_start) or name_start.startswith(name)
+        loader = TestUtil.FilteredByModuleTestLoader(needs_module)
         return loader
 
     def test_load_tests(self):
         test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing']
-        loader = self._create_loader('bzrlib.tests.test_sampler.DemoTest')
+        loader = self._create_loader('bzrlib.tests.test_samp')
+
+        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
+        self.assertEquals(test_list, _test_ids(suite))
+
+    def test_load_tests_inside_module(self):
+        test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing']
+        loader = self._create_loader('bzrlib.tests.test_sampler.Demo')
 
         suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
         self.assertEquals(test_list, _test_ids(suite))

=== modified file 'doc/developers/HACKING.txt'
--- a/doc/developers/HACKING.txt	2008-04-28 03:52:09 +0000
+++ b/doc/developers/HACKING.txt	2008-05-06 20:21:59 +0000
@@ -250,7 +250,7 @@
 down the track do not break new features or bug fixes that you are
 contributing today.
 
-As of May 2007, Bazaar ships with a test suite containing over 6000 tests
+As of May 2008, Bazaar ships with a test suite containing over 12000 tests
 and growing. We are proud of it and want to remain so. As community
 members, we all benefit from it. Would you trust version control on
 your project to a product *without* a test suite like Bazaar has?
@@ -283,6 +283,28 @@
 This option can be combined with other selftest options (like -x) and
 filter patterns to understand their effect.
 
+Once you understand how to create a list of tests, you can use the --load-list
+option to run only a restricted set of tests that you kept in a file, one test
+id by line. Keep in mind that this will never be sufficient to validate your
+modifications, you still need to run the full test suite for that, but using it
+can help in some cases (like running only the failed tests for some time)::
+
+  ./bzr selftest -- load-list my_failing_tests
+
+This option can also be combined with other selftest options, including
+patterns. It has some drawbacks though, the list can become out of date pretty
+quick when doing Test Driven Development.
+
+To address this concern, there is another way to run a restricted set of tests:
+the --starting-with option will run only the tests whose name starts with the
+specified string. It will also avoid loading the other tests and as a
+consequence starts running your tests quicker::
+
+  ./bzr selftest --starting-with bzrlib.blackbox
+
+This option can be combined with all the other selftest options including
+--load-list. The later is rarely used but allows to run a subset of a list of
+failing tests for example.
 
 Writing Tests
 =============



More information about the bazaar-commits mailing list