~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

  • Committer: Martin Pool
  • Date: 2005-09-16 07:38:10 UTC
  • Revision ID: mbp@sourcefrog.net-20050916073810-1f358be198c9ed91
- fix bug in committing files that are renamed but not modified

- add test for this

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