Rev 3671: (vila) selftest --starting-with now accepts multiple values in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Sep 1 10:01:33 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3671
revision-id: pqm at pqm.ubuntu.com-20080901090124-w1cxlizdk4g3mstv
parent: pqm at pqm.ubuntu.com-20080901083105-x0h6ocy17ktfc9s4
parent: v.ladeuil+lp at free.fr-20080901075417-tc1kpoatx20bq7jn
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2008-09-01 10:01:24 +0100
message:
  (vila) selftest --starting-with now accepts multiple values
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
  bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
    ------------------------------------------------------------
    revno: 3668.3.2
    revision-id: v.ladeuil+lp at free.fr-20080901075417-tc1kpoatx20bq7jn
    parent: v.ladeuil+lp at free.fr-20080901062657-22rkabbjdl5ho5h9
    parent: v.ladeuil+lp at free.fr-20080901075302-xbdu6hxmllepi6xg
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk2
    timestamp: Mon 2008-09-01 09:54:17 +0200
    message:
      Fix pqm failure by adding a space
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
        ------------------------------------------------------------
        revno: 3649.6.6
        revision-id: v.ladeuil+lp at free.fr-20080901075302-xbdu6hxmllepi6xg
        parent: v.ladeuil+lp at free.fr-20080831105107-kfmrr44gizyp6ckf
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: selftest-multiple-start
        timestamp: Mon 2008-09-01 09:53:02 +0200
        message:
          Wow, missing space making pqm fail.
        modified:
          NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3668.3.1
    revision-id: v.ladeuil+lp at free.fr-20080901062657-22rkabbjdl5ho5h9
    parent: pqm at pqm.ubuntu.com-20080830091000-3oibqwlrxvdpgo5l
    parent: v.ladeuil+lp at free.fr-20080831105107-kfmrr44gizyp6ckf
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk2
    timestamp: Mon 2008-09-01 08:26:57 +0200
    message:
      selftest --starting-with now accepts multiple values
    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
      bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
    ------------------------------------------------------------
    revno: 3649.6.5
    revision-id: v.ladeuil+lp at free.fr-20080831105107-kfmrr44gizyp6ckf
    parent: v.ladeuil+lp at free.fr-20080831104654-15d4mljmyyuakwx1
    parent: pqm at pqm.ubuntu.com-20080830091000-3oibqwlrxvdpgo5l
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: selftest-multiple-start
    timestamp: Sun 2008-08-31 12:51:07 +0200
    message:
      merge bzr.dev at 3668
    added:
      bzrlib/transport/ftp/          ftp-20080611185801-3vm145h8dmnfgh25-1
      bzrlib/transport/ftp/_gssapi.py _gssapi.py-20080611190840-7ejrtp884bk5eu72-2
      tools/packaging/               packaging-20080825202834-3j433iaawnt72wqa-1
      tools/packaging/build-packages.sh buildpackages.sh-20080821102059-fzlodktas65qmo1k-1
      tools/packaging/update-changelogs.sh updatechangelogs.sh-20080821102059-fzlodktas65qmo1k-2
      tools/packaging/update-packaging-branches.sh updatepackagingbranc-20080825210254-6is8ciit1yzyd3a2-1
    renamed:
      bzrlib/transport/ftp.py => bzrlib/transport/ftp/__init__.py ftp.py-20051116161804-58dc9506548c2a53
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
      bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
      bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
      bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
      bzrlib/tests/test_fetch.py     testfetch.py-20050825090644-f73e07e7dfb1765a
      bzrlib/tests/test_info.py      test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
      bzrlib/tests/test_merge.py     testmerge.py-20050905070950-c1b5aa49ff911024
      bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
      bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
      bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
      bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
      bzrlib/tests/test_upgrade_stacked.py test_upgrade_stacked-20080804072225-jd13yami19nskns5-1
      bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
      bzrlib/tests/tree_implementations/test_walkdirs.py test_walkdirs.py-20060729160421-gmjnkotqgxdh98ce-1
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
      bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
      bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
      bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
      doc/developers/ppa.txt         ppa.txt-20080722055539-606u7t2z32t3ae4w-1
    ------------------------------------------------------------
    revno: 3649.6.4
    revision-id: v.ladeuil+lp at free.fr-20080831104654-15d4mljmyyuakwx1
    parent: v.ladeuil+lp at free.fr-20080830083535-8qdpr48ehdxp7cjh
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: selftest-multiple-start
    timestamp: Sun 2008-08-31 12:46:54 +0200
    message:
      selftest --starting-with now accepts multiple values.
      
      * bzrlib/tests/test_selftest.py:
      (TestSelftestFiltering.test_condition_id_startswith)
      (TestSelftestFiltering.test_filter_suite_by_id_startswith): Updated.
      
      * bzrlib/tests/blackbox/test_selftest.py:
      (TestSelftestStartingWith): Add test for multiple arguments.
      
      * bzrlib/tests/__init__.py:
      (condition_id_startswith, filter_suite_by_id_startswith): Now
      accepts a list of strings to start with.
      (test_suite): 'starting_with' is now a list.
      
      * bzrlib/builtins.py:
      (cmd_selftest): Allows multiple --starting-with option.
    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
      bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
=== modified file 'NEWS'
--- a/NEWS	2008-08-31 19:39:01 +0000
+++ b/NEWS	2008-09-01 09:01:24 +0000
@@ -93,6 +93,9 @@
       prefixes so that one can say ``bzr selftest -s bp.loom`` instead of
       ``bzr selftest -s bzrlib.plugins.loom``. (Vincent Ladeuil)
 
+    * ``selftest``'s ``--starting-with`` option now accepts multiple values.
+      (Vincent Ladeuil)
+
   INTERNALS:
 
     * A new plugin interface, ``bzrlib.log.log_adapters``, has been added.

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-08-23 18:54:47 +0000
+++ b/bzrlib/builtins.py	2008-08-31 10:46:54 +0000
@@ -2661,9 +2661,10 @@
                             help='Load a test id list from a text file.'),
                      ListOption('debugflag', type=str, short_name='E',
                                 help='Turn on a selftest debug flag.'),
-                     Option('starting-with', type=str, argname='TESTID',
-                            short_name='s',
-                            help='Load only the tests starting with TESTID.'),
+                     ListOption('starting-with', type=str, argname='TESTID',
+                                param_name='starting_with', 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-09-01 06:19:29 +0000
+++ b/bzrlib/tests/__init__.py	2008-09-01 09:01:24 +0000
@@ -2303,15 +2303,18 @@
     return condition
 
 
-def condition_id_startswith(start):
+def condition_id_startswith(starts):
     """Create a condition filter verifying that test's id starts with a string.
     
-    :param start: A string.
-    :return: A callable that returns True if the test's id starts with the
-        given string.
+    :param starts: A list of string.
+    :return: A callable that returns True if the test's id starts with one of 
+        the given strings.
     """
     def condition(test):
-        return test.id().startswith(start)
+        for start in starts:
+            if test.id().startswith(start):
+                return True
+        return False
     return condition
 
 
@@ -2339,7 +2342,7 @@
         test case which should be included in the result.
     :return: A suite which contains the tests found in suite that pass
         condition.
-    """ 
+    """
     result = []
     for test in iter_suite_tests(suite):
         if condition(test):
@@ -2353,7 +2356,7 @@
     :param suite:           the source suite
     :param pattern:         pattern that names must match
     :returns: the newly created suite
-    """ 
+    """
     condition = condition_id_re(pattern)
     result_suite = filter_suite_by_condition(suite, condition)
     return result_suite
@@ -2375,7 +2378,7 @@
     """Create a test suite by filtering another one.
 
     :param suite: The source suite.
-    :param start: A string the test id must start with.
+    :param start: A list of string the test id must start with one of.
     :returns: the newly created suite
     """
     condition = condition_id_startswith(start)
@@ -2428,7 +2431,7 @@
         suite matching the condition, and the second contains the remainder
         from suite. The order within each output suite is the same as it was in
         suite.
-    """ 
+    """
     matched = []
     did_not_match = []
     for test in iter_suite_tests(suite):
@@ -2450,7 +2453,7 @@
         suite matching pattern, and the second contains the remainder from
         suite. The order within each output suite is the same as it was in
         suite.
-    """ 
+    """
     return split_suite_by_condition(suite, condition_id_re(pattern))
 
 
@@ -2891,17 +2894,21 @@
 
     loader = TestUtil.TestLoader()
 
-    if starting_with is not None:
-        starting_with = test_prefix_alias_registry.resolve_alias(starting_with)
+    if starting_with:
+        starting_with = [test_prefix_alias_registry.resolve_alias(start)
+                         for start in starting_with]
         # We take precedence over keep_only because *at loading time* using
         # both options means we will load less tests for the same final result.
         def interesting_module(name):
-            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)
-                )
+            for start in starting_with:
+                if (
+                    # Either the module name starts with the specified string
+                    name.startswith(start)
+                    # or it may contain tests starting with the specified string
+                    or start.startswith(name)
+                    ):
+                    return True
+            return False
         loader = TestUtil.FilteredByModuleTestLoader(interesting_module)
 
     elif keep_only is not None:
@@ -2967,7 +2974,7 @@
             reload(sys)
             sys.setdefaultencoding(default_encoding)
 
-    if starting_with is not None:
+    if starting_with:
         suite = filter_suite_by_id_startswith(suite, starting_with)
 
     if keep_only is not None:
@@ -2976,7 +2983,7 @@
         suite = filter_suite_by_id_list(suite, id_filter)
         # 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:
+        if starting_with:
             # 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.

=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py	2008-07-19 15:00:27 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py	2008-08-31 10:46:54 +0000
@@ -572,9 +572,18 @@
 
 class TestSelftestStartingWith(TestCase):
 
-    def test_starting_with(self):
+    def test_starting_with_single_argument(self):
         out, err = self.run_bzr(
             ['selftest', '--starting-with', self.id(), '--list'])
         self.assertContainsRe(out, "Listed 1 test in")
         self.assertContainsRe(out, self.id())
 
+    def test_starting_with_multiple_argument(self):
+        out, err = self.run_bzr(
+            ['selftest',
+             '--starting-with', self.id(),
+             '--starting-with', 'bzrlib.tests.test_sampler',
+             '--list'])
+        self.assertContainsRe(out, "Listed 2 tests in")
+        self.assertContainsRe(out, self.id())
+        self.assertContainsRe(out, 'bzrlib.tests.test_sampler')

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2008-08-30 08:39:10 +0000
+++ b/bzrlib/tests/test_selftest.py	2008-08-31 10:51:07 +0000
@@ -1784,13 +1784,14 @@
 
     def test_condition_id_startswith(self):
         klass = 'bzrlib.tests.test_selftest.TestSelftestFiltering.'
-        start = klass + 'test_condition_id_starts'
-        test_names = [klass + 'test_condition_id_startswith']
+        start1 = klass + 'test_condition_id_starts'
+        start2 = klass + 'test_condition_id_in'
+        test_names = [ klass + 'test_condition_id_in_list',
+                      klass + 'test_condition_id_startswith',
+                     ]
         filtered_suite = filter_suite_by_condition(
-            self.suite, tests.condition_id_startswith(start))
-        my_pattern = 'TestSelftestFiltering.*test_condition_id_startswith'
-        re_filtered = filter_suite_by_re(self.suite, my_pattern)
-        self.assertEqual(_test_ids(re_filtered), _test_ids(filtered_suite))
+            self.suite, tests.condition_id_startswith([start1, start2]))
+        self.assertEqual(test_names, _test_ids(filtered_suite))
 
     def test_condition_isinstance(self):
         filtered_suite = filter_suite_by_condition(self.suite,
@@ -1849,16 +1850,19 @@
 
     def test_filter_suite_by_id_startswith(self):
         # By design this test may fail if another test is added whose name also
-        # begins with the start value used.
+        # begins with one of 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']
-        filtered_suite = tests.filter_suite_by_id_startswith(self.suite, start)
-        filtered_names = _test_ids(filtered_suite)
+        start1 = klass + 'test_filter_suite_by_id_starts'
+        start2 = klass + 'test_filter_suite_by_id_li'
+        test_list = [klass + 'test_filter_suite_by_id_list',
+                     klass + 'test_filter_suite_by_id_startswith',
+                     ]
+        filtered_suite = tests.filter_suite_by_id_startswith(
+            self.suite, [start1, start2])
         self.assertEqual(
-            filtered_names,
-            ['bzrlib.tests.test_selftest.'
-             'TestSelftestFiltering.test_filter_suite_by_id_startswith'])
+            test_list,
+            _test_ids(filtered_suite),
+            )
 
     def test_preserve_input(self):
         # NB: Surely this is something in the stdlib to do this?




More information about the bazaar-commits mailing list