Rev 4267: Remove noise from bzr selftest --list-only so that it is easier to use in scripts. in http://people.ubuntu.com/~robertc/baz2.0/pending/tests.output

Robert Collins robertc at robertcollins.net
Wed Apr 8 08:47:05 BST 2009


At http://people.ubuntu.com/~robertc/baz2.0/pending/tests.output

------------------------------------------------------------
revno: 4267
revision-id: robertc at robertcollins.net-20090408074650-14g8s76qcp5hyy4d
parent: pqm at pqm.ubuntu.com-20090407180335-g11gve6533bv8lei
committer: Robert Collins <robertc at robertcollins.net>
branch nick: tests.output
timestamp: Wed 2009-04-08 17:46:50 +1000
message:
  Remove noise from bzr selftest --list-only so that it is easier to use in scripts.
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-04-07 14:49:24 +0000
+++ b/bzrlib/builtins.py	2009-04-08 07:46:50 +0000
@@ -3253,7 +3253,7 @@
                     bzrlib.version_string,
                     bzrlib._format_version_tuple(sys.version_info),
                     )
-        print
+            print
         if testspecs_list is not None:
             pattern = '|'.join(testspecs_list)
         else:
@@ -3299,10 +3299,11 @@
         finally:
             if benchfile is not None:
                 benchfile.close()
-        if result:
-            note('tests passed')
-        else:
-            note('tests failed')
+        if not list_only:
+            if result:
+                note('tests passed')
+            else:
+                note('tests failed')
         return int(not result)
 
 

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-04-07 13:56:43 +0000
+++ b/bzrlib/tests/__init__.py	2009-04-08 07:46:50 +0000
@@ -542,7 +542,7 @@
             for t in iter_suite_tests(test):
                 self.stream.writeln("%s" % (t.id()))
                 run += 1
-            actionTaken = "Listed"
+            return None
         else:
             try:
                 import testtools
@@ -2653,6 +2653,8 @@
     for decorator in decorators:
         suite = decorator(suite)
     result = runner.run(suite)
+    if list_only:
+        return True
     if strict:
         return result.wasStrictlySuccessful()
     else:

=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py	2009-04-08 07:46:50 +0000
@@ -487,9 +487,9 @@
 class TestSelftestListOnly(TestCase):
 
     @staticmethod
-    def _parse_test_list(lines, newlines_in_header=1):
+    def _parse_test_list(lines, newlines_in_header=0):
         "Parse a list of lines into a tuple of 3 lists (header,body,footer)."
-        in_header = True
+        in_header = newlines_in_header != 0
         in_footer = False
         header = []
         body = []
@@ -518,10 +518,11 @@
     def test_list_only(self):
         # check that bzr selftest --list-only works correctly
         out,err = self.run_bzr('selftest selftest --list-only')
-        self.assertEndsWith(err, 'tests passed\n')
         (header,body,footer) = self._parse_test_list(out.splitlines())
         num_tests = len(body)
-        self.assertContainsRe(footer[0], 'Listed %s tests in' % num_tests)
+        self.assertLength(0, header)
+        self.assertLength(0, footer)
+        self.assertEqual('', err)
 
     def test_list_only_filtered(self):
         # check that a filtered --list-only works, both include and exclude
@@ -551,7 +552,7 @@
         out_rand,err_rand = self.run_bzr(['selftest', '--list-only',
                                           'selftest', '--randomize', 'now'])
         (header_rand,tests_rand,dummy) = self._parse_test_list(
-            out_rand.splitlines(), 2)
+            out_rand.splitlines(), 1)
         # XXX: The following line asserts that the randomized order is not the
         # same as the default order.  It is just possible that they'll get
         # randomized into the same order and this will falsely fail, but
@@ -566,7 +567,7 @@
         out_rand2,err_rand2 = self.run_bzr(['selftest', '--list-only',
                                             'selftest', '--randomize', seed])
         (header_rand2,tests_rand2,dummy) = self._parse_test_list(
-            out_rand2.splitlines(), 2)
+            out_rand2.splitlines(), 1)
         self.assertEqual(tests_rand, tests_rand2)
 
 
@@ -581,7 +582,8 @@
         fl.close()
         out, err = self.run_bzr(
             ['selftest', '--load-list', test_list_fname, '--list'])
-        self.assertContainsRe(out, "Listed 1 test in")
+        self.assertContainsRe(out, "TestSelftestWithIdList")
+        self.assertLength(1, out.splitlines())
 
     def test_load_unknown(self):
         out, err = self.run_bzr('selftest --load-list I_do_not_exist ',
@@ -593,7 +595,6 @@
     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):
@@ -602,6 +603,5 @@
              '--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')




More information about the bazaar-commits mailing list