~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-09-04 03:32:17 UTC
  • mfrom: (974.1.52)
  • mto: (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1178.
  • Revision ID: aaron.bentley@utoronto.ca-20050904033217-821a797652305c14
Disabled urlgrabber

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import tempfile
21
21
import os
22
22
import sys
23
 
import errno
24
23
import subprocess
25
 
import shutil
26
24
 
27
 
import testsweet
 
25
from testsweet import run_suite
28
26
import bzrlib.commands
29
27
 
30
28
import bzrlib.trace
68
66
 
69
67
        hdlr = logging.StreamHandler(self._log_file)
70
68
        hdlr.setLevel(logging.DEBUG)
71
 
        hdlr.setFormatter(logging.Formatter('%(levelname)8s  %(message)s'))
 
69
        hdlr.setFormatter(logging.Formatter('%(levelname)4.4s  %(message)s'))
72
70
        logging.getLogger('').addHandler(hdlr)
73
71
        logging.getLogger('').setLevel(logging.DEBUG)
74
72
        self._log_hdlr = hdlr
109
107
        
110
108
        
111
109
    def check_inventory_shape(self, inv, shape):
112
 
        """Compare an inventory to a list of expected names.
 
110
        """
 
111
        Compare an inventory to a list of expected names.
113
112
 
114
113
        Fail if they are not precisely equal.
115
114
        """
185
184
            self.fail("contents of %s not as expected")
186
185
 
187
186
    def _make_test_root(self):
 
187
        import os
 
188
        import shutil
 
189
        import tempfile
 
190
        
188
191
        if TestCaseInTempDir.TEST_ROOT is not None:
189
192
            return
190
 
        i = 0
191
 
        while True:
192
 
            root = 'test%04d.tmp' % i
193
 
            try:
194
 
                os.mkdir(root)
195
 
            except OSError, e:
196
 
                if e.errno == errno.EEXIST:
197
 
                    i += 1
198
 
                    continue
199
 
                else:
200
 
                    raise
201
 
            # successfully created
202
 
            TestCaseInTempDir.TEST_ROOT = os.path.abspath(root)
203
 
            break
 
193
        TestCaseInTempDir.TEST_ROOT = os.path.abspath(
 
194
                                 tempfile.mkdtemp(suffix='.tmp',
 
195
                                                  prefix=self._TEST_NAME + '-',
 
196
                                                  dir=os.curdir))
 
197
    
204
198
        # make a fake bzr directory there to prevent any tests propagating
205
199
        # up onto the source directory's real branch
206
200
        os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))
210
204
        import os
211
205
        self._make_test_root()
212
206
        self._currentdir = os.getcwdu()
213
 
        short_id = self.id().replace('bzrlib.selftest.', '') \
214
 
                   .replace('__main__.', '')
215
 
        self.test_dir = os.path.join(self.TEST_ROOT, short_id)
 
207
        self.test_dir = os.path.join(self.TEST_ROOT, self.id())
216
208
        os.mkdir(self.test_dir)
217
209
        os.chdir(self.test_dir)
218
210
        
296
288
 
297
289
 
298
290
def selftest(verbose=False, pattern=".*"):
299
 
    """Run the whole test suite under the enhanced runner"""
300
 
    return testsweet.run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
 
291
    return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
301
292
 
302
293
 
303
294
def test_suite():
304
 
    """Build and return TestSuite for the whole program."""
305
295
    from bzrlib.selftest.TestUtil import TestLoader, TestSuite
306
296
    import bzrlib, bzrlib.store, bzrlib.inventory, bzrlib.branch
307
297
    import bzrlib.osutils, bzrlib.commands, bzrlib.merge3, bzrlib.plugin
315
305
 
316
306
    testmod_names = \
317
307
                  ['bzrlib.selftest.MetaTestLog',
 
308
                   'bzrlib.selftest.test_parent',
318
309
                   'bzrlib.selftest.testinv',
319
 
                   'bzrlib.selftest.test_commit',
 
310
                   'bzrlib.selftest.testfetch',
320
311
                   'bzrlib.selftest.versioning',
 
312
                   'bzrlib.selftest.whitebox',
321
313
                   'bzrlib.selftest.testmerge3',
322
314
                   'bzrlib.selftest.testhashcache',
323
315
                   'bzrlib.selftest.teststatus',
324
316
                   'bzrlib.selftest.testlog',
 
317
                   'bzrlib.selftest.blackbox',
325
318
                   'bzrlib.selftest.testrevisionnamespaces',
326
319
                   'bzrlib.selftest.testbranch',
327
320
                   'bzrlib.selftest.testrevision',
328
321
                   'bzrlib.selftest.test_merge_core',
329
322
                   'bzrlib.selftest.test_smart_add',
330
323
                   'bzrlib.selftest.testdiff',
331
 
                   'bzrlib.selftest.test_parent',
332
 
                   'bzrlib.selftest.test_xml',
333
 
                   'bzrlib.selftest.test_weave',
334
 
                   'bzrlib.selftest.testfetch',
335
 
                   'bzrlib.selftest.whitebox',
 
324
                   'bzrlib.fetch',
336
325
                   'bzrlib.selftest.teststore',
337
 
                   'bzrlib.selftest.blackbox',
338
326
                   ]
339
327
 
340
328
    for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,