Rev 2599: Remove obsolete --clean-output, --keep-output, --numbered-dirs selftest options (thanks Alexander) in http://sourcefrog.net/bzr/test-cleanup

Martin Pool mbp at sourcefrog.net
Wed Jul 11 02:44:48 BST 2007


At http://sourcefrog.net/bzr/test-cleanup

------------------------------------------------------------
revno: 2599
revision-id: mbp at sourcefrog.net-20070711014446-up0nkhg2u8nvupyl
parent: pqm at pqm.ubuntu.com-20070710021221-8o98e4q8vcpaarnk
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: test-cleanup
timestamp: Wed 2007-07-11 11:44:46 +1000
message:
  Remove obsolete --clean-output, --keep-output, --numbered-dirs selftest options (thanks Alexander)
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	2007-07-10 01:37:27 +0000
+++ b/NEWS	2007-07-11 01:44:46 +0000
@@ -18,7 +18,9 @@
 
   TESTING:
 
-    * None yet ...
+    * Remove selftest ``--clean-output``, ``--numbered-dirs`` and
+      ``--keep-output`` options, which are obsolete now that tests
+      are done within directories in $TMPDIR.  (Martin Pool)
 
 
 bzr 0.18rc1  2007-07-10

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2007-07-06 17:21:57 +0000
+++ b/bzrlib/builtins.py	2007-07-11 01:44:46 +0000
@@ -2360,18 +2360,14 @@
     modified by plugins will not be tested, and tests provided by plugins will
     not be run.
 
+    Tests that need working space on disk use a common temporary directory, 
+    typically inside $TMPDIR or /tmp.
+
     examples::
         bzr selftest ignore
             run only tests relating to 'ignore'
         bzr --no-plugins selftest -v
             disable plugins and list tests as they're run
-
-    For each test, that needs actual disk access, bzr create their own
-    subdirectory in the temporary testing directory (testXXXX.tmp).
-    By default the name of such subdirectory is based on the name of the test.
-    If option '--numbered-dirs' is given, bzr will use sequent numbers
-    of running tests to create such subdirectories. This is default behavior
-    on Windows because of path length limitation.
     """
     # NB: this is used from the class without creating an instance, which is
     # why it does not have a self parameter.
@@ -2397,8 +2393,6 @@
                              help='stop when one test fails',
                              short_name='1',
                              ),
-                     Option('keep-output',
-                            help='keep output directories when tests fail'),
                      Option('transport',
                             help='Use a different transport by default '
                                  'throughout the test suite.',
@@ -2410,15 +2404,10 @@
                      Option('cache-dir', type=str,
                             help='a directory to cache intermediate'
                                  ' benchmark steps'),
-                     Option('clean-output',
-                            help='clean temporary tests directories'
-                                 ' without running tests'),
                      Option('first',
                             help='run all tests, but run specified tests first',
                             short_name='f',
                             ),
-                     Option('numbered-dirs',
-                            help='use numbered dirs for TestCaseInTempDir'),
                      Option('list-only',
                             help='list the tests instead of running them'),
                      Option('randomize', type=str, argname="SEED",
@@ -2432,27 +2421,15 @@
     encoding_type = 'replace'
 
     def run(self, testspecs_list=None, verbose=None, one=False,
-            keep_output=False, transport=None, benchmark=None,
-            lsprof_timed=None, cache_dir=None, clean_output=False,
-            first=False, numbered_dirs=None, list_only=False,
+            transport=None, benchmark=None,
+            lsprof_timed=None, cache_dir=None,
+            first=False, list_only=False,
             randomize=None, exclude=None):
         import bzrlib.ui
         from bzrlib.tests import selftest
         import bzrlib.benchmarks as benchmarks
         from bzrlib.benchmarks import tree_creator
 
-        if clean_output:
-            from bzrlib.tests import clean_selftest_output
-            clean_selftest_output()
-            return 0
-        if keep_output:
-            warning("notice: selftest --keep-output "
-                    "is no longer supported; "
-                    "test output is always removed")
-
-        if numbered_dirs is None and sys.platform == 'win32':
-            numbered_dirs = True
-
         if cache_dir is not None:
             tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
         print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
@@ -2474,15 +2451,14 @@
                 verbose = False
             benchfile = None
         try:
-            result = selftest(verbose=verbose, 
+            result = selftest(verbose=verbose,
                               pattern=pattern,
-                              stop_on_failure=one, 
+                              stop_on_failure=one,
                               transport=transport,
                               test_suite_factory=test_suite_factory,
                               lsprof_timed=lsprof_timed,
                               bench_history=benchfile,
                               matching_tests_first=first,
-                              numbered_dirs=numbered_dirs,
                               list_only=list_only,
                               random_seed=randomize,
                               exclude_pattern=exclude

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2007-07-05 00:12:25 +0000
+++ b/bzrlib/tests/__init__.py	2007-07-11 01:44:46 +0000
@@ -165,7 +165,6 @@
     def __init__(self, stream, descriptions, verbosity,
                  bench_history=None,
                  num_tests=None,
-                 use_numbered_dirs=False,
                  ):
         """Construct new TestResult.
 
@@ -196,7 +195,6 @@
         self.skip_count = 0
         self.unsupported = {}
         self.count = 0
-        self.use_numbered_dirs = use_numbered_dirs
         self._overall_start_time = time.time()
     
     def extractBenchmarkTime(self, testCase):
@@ -303,8 +301,6 @@
         for test, err in errors:
             self.stream.writeln(self.separator1)
             self.stream.write("%s: " % flavour)
-            if self.use_numbered_dirs:
-                self.stream.write('#%d ' % test.number)
             self.stream.writeln(self.getDescription(test))
             if getattr(test, '_get_log', None) is not None:
                 print >>self.stream
@@ -333,10 +329,9 @@
                  bench_history=None,
                  num_tests=None,
                  pb=None,
-                 use_numbered_dirs=False,
                  ):
         ExtendedTestResult.__init__(self, stream, descriptions, verbosity,
-            bench_history, num_tests, use_numbered_dirs)
+            bench_history, num_tests)
         if pb is None:
             self.pb = self.ui.nested_progress_bar()
             self._supplied_pb = False
@@ -378,11 +373,7 @@
                 + self._shortened_test_description(test))
 
     def _test_description(self, test):
-        if self.use_numbered_dirs:
-            return '#%d %s' % (self.count,
-                               self._shortened_test_description(test))
-        else:
-            return self._shortened_test_description(test)
+        return self._shortened_test_description(test)
 
     def report_error(self, test, err):
         self.pb.note('ERROR: %s\n    %s\n', 
@@ -447,19 +438,12 @@
         # width needs space for 6 char status, plus 1 for slash, plus 2 10-char
         # numbers, plus a trailing blank
         # when NUMBERED_DIRS: plus 5 chars on test number, plus 1 char on space
-        if self.use_numbered_dirs:
-            self.stream.write('%5d ' % self.count)
-            self.stream.write(self._ellipsize_to_right(name,
-                                osutils.terminal_width()-36))
-        else:
-            self.stream.write(self._ellipsize_to_right(name,
-                                osutils.terminal_width()-30))
+        self.stream.write(self._ellipsize_to_right(name,
+                          osutils.terminal_width()-30))
         self.stream.flush()
 
     def _error_summary(self, err):
         indent = ' ' * 4
-        if self.use_numbered_dirs:
-            indent += ' ' * 6
         return '%s%s' % (indent, err[1])
 
     def report_error(self, test, err):
@@ -507,14 +491,12 @@
                  descriptions=0,
                  verbosity=1,
                  bench_history=None,
-                 use_numbered_dirs=False,
                  list_only=False
                  ):
         self.stream = unittest._WritelnDecorator(stream)
         self.descriptions = descriptions
         self.verbosity = verbosity
         self._bench_history = bench_history
-        self.use_numbered_dirs = use_numbered_dirs
         self.list_only = list_only
 
     def run(self, test):
@@ -529,7 +511,6 @@
                               self.verbosity,
                               bench_history=self._bench_history,
                               num_tests=test.countTestCases(),
-                              use_numbered_dirs=self.use_numbered_dirs,
                               )
         result.stop_early = self.stop_on_failure
         result.report_starting()
@@ -1894,7 +1875,6 @@
     """
 
     OVERRIDE_PYTHON = 'python'
-    use_numbered_dirs = False
 
     def check_file_contents(self, filename, expect):
         self.log("check contents of file %s" % filename)
@@ -2173,16 +2153,11 @@
               stop_on_failure=False,
               transport=None, lsprof_timed=None, bench_history=None,
               matching_tests_first=None,
-              numbered_dirs=None,
               list_only=False,
               random_seed=None,
               exclude_pattern=None,
               ):
-    use_numbered_dirs = bool(numbered_dirs)
-
     TestCase._gather_lsprof_in_benchmarks = lsprof_timed
-    if numbered_dirs is not None:
-        TestCaseInTempDir.use_numbered_dirs = use_numbered_dirs
     if verbose:
         verbosity = 2
     else:
@@ -2191,7 +2166,6 @@
                             descriptions=0,
                             verbosity=verbosity,
                             bench_history=bench_history,
-                            use_numbered_dirs=use_numbered_dirs,
                             list_only=list_only,
                             )
     runner.stop_on_failure=stop_on_failure
@@ -2229,7 +2203,6 @@
              lsprof_timed=None,
              bench_history=None,
              matching_tests_first=None,
-             numbered_dirs=None,
              list_only=False,
              random_seed=None,
              exclude_pattern=None):
@@ -2256,7 +2229,6 @@
                      lsprof_timed=lsprof_timed,
                      bench_history=bench_history,
                      matching_tests_first=matching_tests_first,
-                     numbered_dirs=numbered_dirs,
                      list_only=list_only,
                      random_seed=random_seed,
                      exclude_pattern=exclude_pattern)
@@ -2455,24 +2427,6 @@
             raise
 
 
-def clean_selftest_output(root=None, quiet=False):
-    """Remove all selftest output directories from root directory.
-
-    :param  root:   root directory for clean
-                    (if ommitted or None then clean current directory).
-    :param  quiet:  suppress report about deleting directories
-    """
-    import re
-    re_dir = re.compile(r'''test\d\d\d\d\.tmp''')
-    if root is None:
-        root = u'.'
-    for i in os.listdir(root):
-        if os.path.isdir(i) and re_dir.match(i):
-            if not quiet:
-                print 'delete directory:', i
-            _rmtree_temp_dir(i)
-
-
 class Feature(object):
     """An operating system Feature."""
 

=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py	2007-07-04 08:56:14 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py	2007-07-11 01:44:46 +0000
@@ -472,43 +472,6 @@
                 ['file-id', 'foobarbaz'])
 
 
-class TestSelftestCleanOutput(TestCaseInTempDir):
-
-    def test_clean_output(self):
-        # check that 'bzr selftest --clean-output' works correct
-        dirs = ('test0000.tmp', 'test0001.tmp', 'bzrlib', 'tests')
-        files = ('bzr', 'setup.py', 'test9999.tmp')
-        for i in dirs:
-            os.mkdir(i)
-        for i in files:
-            f = file(i, 'wb')
-            f.write('content of ')
-            f.write(i)
-            f.close()
-
-        root = os.getcwdu()
-        before = os.listdir(root)
-        before.sort()
-        self.assertEquals(['bzr','bzrlib','setup.py',
-                           'test0000.tmp','test0001.tmp',
-                           'test9999.tmp','tests'],
-                           before)
-
-        out, err = self.run_bzr('selftest --clean-output',
-                                working_dir=root)
-
-        self.assertEquals(['delete directory: test0000.tmp',
-                          'delete directory: test0001.tmp'],
-                          sorted(out.splitlines()))
-        self.assertEquals('', err)
-
-        after = os.listdir(root)
-        after.sort()
-        self.assertEquals(['bzr','bzrlib','setup.py',
-                           'test9999.tmp','tests'],
-                           after)
-
-
 class TestSelftestListOnly(TestCase):
 
     @staticmethod

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2007-07-02 05:26:25 +0000
+++ b/bzrlib/tests/test_selftest.py	2007-07-11 01:44:46 +0000
@@ -50,7 +50,6 @@
                           TestUtil,
                           TextTestRunner,
                           UnavailableFeature,
-                          clean_selftest_output,
                           iter_suite_tests,
                           filter_suite_by_re,
                           sort_suite_by_re,
@@ -1512,40 +1511,6 @@
         self.assertEqual([True], factory_called)
 
 
-class TestSelftestCleanOutput(TestCaseInTempDir):
-
-    def test_clean_output(self):
-        # test functionality of clean_selftest_output()
-        self.build_tree(['test0000.tmp/', 'test0001.tmp/',
-                         'bzrlib/', 'tests/',
-                         'bzr', 'setup.py', 'test9999.tmp'])
-
-        root = os.getcwdu()
-        before = os.listdir(root)
-        before.sort()
-        self.assertEquals(['bzr','bzrlib','setup.py',
-                           'test0000.tmp','test0001.tmp',
-                           'test9999.tmp','tests'],
-                           before)
-        clean_selftest_output(root, quiet=True)
-        after = os.listdir(root)
-        after.sort()
-        self.assertEquals(['bzr','bzrlib','setup.py',
-                           'test9999.tmp','tests'],
-                           after)
-
-    def test_clean_readonly(self):
-        # test for delete read-only files
-        self.build_tree(['test0000.tmp/', 'test0000.tmp/foo'])
-        osutils.make_readonly('test0000.tmp/foo')
-        root = os.getcwdu()
-        before = os.listdir(root);  before.sort()
-        self.assertEquals(['test0000.tmp'], before)
-        clean_selftest_output(root, quiet=True)
-        after = os.listdir(root);   after.sort()
-        self.assertEquals([], after)
-
-
 class TestKnownFailure(TestCase):
 
     def test_known_failure(self):




More information about the bazaar-commits mailing list