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