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
111
109
def check_inventory_shape(self, inv, shape):
112
"""Compare an inventory to a list of expected names.
111
Compare an inventory to a list of expected names.
114
113
Fail if they are not precisely equal.
185
184
self.fail("contents of %s not as expected")
187
186
def _make_test_root(self):
188
191
if TestCaseInTempDir.TEST_ROOT is not None:
192
root = 'test%04d.tmp' % i
196
if e.errno == errno.EEXIST:
201
# successfully created
202
TestCaseInTempDir.TEST_ROOT = os.path.abspath(root)
193
TestCaseInTempDir.TEST_ROOT = os.path.abspath(
194
tempfile.mkdtemp(suffix='.tmp',
195
prefix=self._TEST_NAME + '-',
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'))
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)
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)
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
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',
336
325
'bzrlib.selftest.teststore',
337
'bzrlib.selftest.blackbox',
340
328
for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,