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")
186
188
def _make_test_root(self):
191
189
if TestCaseInTempDir.TEST_ROOT is not None:
193
TestCaseInTempDir.TEST_ROOT = os.path.abspath(
194
tempfile.mkdtemp(suffix='.tmp',
195
prefix=self._TEST_NAME + '-',
193
root = 'test%04d.tmp' % i
197
if e.errno == errno.EEXIST:
202
# successfully created
203
TestCaseInTempDir.TEST_ROOT = os.path.abspath(root)
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'))
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)
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)
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
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',
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',
328
341
for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,