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
109
111
def check_inventory_shape(self, inv, shape):
111
Compare an inventory to a list of expected names.
112
"""Compare an inventory to a list of expected names.
113
114
Fail if they are not precisely equal.
184
185
self.fail("contents of %s not as expected")
186
187
def _make_test_root(self):
191
188
if TestCaseInTempDir.TEST_ROOT is not None:
193
TestCaseInTempDir.TEST_ROOT = os.path.abspath(
194
tempfile.mkdtemp(suffix='.tmp',
195
prefix=self._TEST_NAME + '-',
192
root = 'test%04d.tmp' % i
196
if e.errno == errno.EEXIST:
201
# successfully created
202
TestCaseInTempDir.TEST_ROOT = os.path.abspath(root)
198
204
# make a fake bzr directory there to prevent any tests propagating
199
205
# up onto the source directory's real branch
200
206
os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))
205
211
self._make_test_root()
206
212
self._currentdir = os.getcwdu()
207
self.test_dir = os.path.join(self.TEST_ROOT, self.id())
213
short_id = self.id().replace('bzrlib.selftest.', '') \
214
.replace('__main__.', '')
215
self.test_dir = os.path.join(self.TEST_ROOT, short_id)
208
216
os.mkdir(self.test_dir)
209
217
os.chdir(self.test_dir)
290
298
def selftest(verbose=False, pattern=".*"):
291
return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
299
"""Run the whole test suite under the enhanced runner"""
300
return testsweet.run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
294
303
def test_suite():
304
"""Build and return TestSuite for the whole program."""
295
305
from bzrlib.selftest.TestUtil import TestLoader, TestSuite
296
306
import bzrlib, bzrlib.store, bzrlib.inventory, bzrlib.branch
297
307
import bzrlib.osutils, bzrlib.commands, bzrlib.merge3, bzrlib.plugin
306
316
testmod_names = \
307
317
['bzrlib.selftest.MetaTestLog',
308
'bzrlib.selftest.test_parent',
309
318
'bzrlib.selftest.testinv',
310
'bzrlib.selftest.testfetch',
319
'bzrlib.selftest.test_commit',
311
320
'bzrlib.selftest.versioning',
312
'bzrlib.selftest.whitebox',
313
321
'bzrlib.selftest.testmerge3',
314
322
'bzrlib.selftest.testhashcache',
315
323
'bzrlib.selftest.teststatus',
316
324
'bzrlib.selftest.testlog',
317
'bzrlib.selftest.blackbox',
318
325
'bzrlib.selftest.testrevisionnamespaces',
319
326
'bzrlib.selftest.testbranch',
320
327
'bzrlib.selftest.testrevision',
321
328
'bzrlib.selftest.test_merge_core',
322
329
'bzrlib.selftest.test_smart_add',
323
330
'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',
325
336
'bzrlib.selftest.teststore',
337
'bzrlib.selftest.blackbox',
328
340
for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,