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
77
75
self._log_file_name = name
77
def run(self, result):
78
self.apply_redirected(None, None, None,
79
unittest.TestCase.run, self, result)
80
81
def tearDown(self):
81
82
logging.getLogger('').removeHandler(self._log_hdlr)
186
193
self.fail("contents of %s not as expected")
188
195
def _make_test_root(self):
189
200
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)
202
TestCaseInTempDir.TEST_ROOT = os.path.abspath(
203
tempfile.mkdtemp(suffix='.tmp',
204
prefix=self._TEST_NAME + '-',
205
207
# make a fake bzr directory there to prevent any tests propagating
206
208
# up onto the source directory's real branch
207
209
os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))
212
214
self._make_test_root()
213
215
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)
216
self.test_dir = os.path.join(self.TEST_ROOT, self.id())
217
217
os.mkdir(self.test_dir)
218
218
os.chdir(self.test_dir)
299
299
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)
300
return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
304
303
def test_suite():
305
"""Build and return TestSuite for the whole program."""
306
304
from bzrlib.selftest.TestUtil import TestLoader, TestSuite
307
305
import bzrlib, bzrlib.store, bzrlib.inventory, bzrlib.branch
308
306
import bzrlib.osutils, bzrlib.commands, bzrlib.merge3, bzrlib.plugin
317
315
testmod_names = \
318
316
['bzrlib.selftest.MetaTestLog',
317
'bzrlib.selftest.test_parent',
319
318
'bzrlib.selftest.testinv',
319
'bzrlib.selftest.testfetch',
320
320
'bzrlib.selftest.versioning',
321
'bzrlib.selftest.whitebox',
321
322
'bzrlib.selftest.testmerge3',
322
323
'bzrlib.selftest.testhashcache',
323
324
'bzrlib.selftest.teststatus',
324
325
'bzrlib.selftest.testlog',
326
'bzrlib.selftest.blackbox',
325
327
'bzrlib.selftest.testrevisionnamespaces',
326
328
'bzrlib.selftest.testbranch',
327
# 'bzrlib.selftest.testrevision',
328
# 'bzrlib.selftest.test_merge_core',
329
'bzrlib.selftest.testrevision',
330
'bzrlib.selftest.test_merge_core',
329
331
'bzrlib.selftest.test_smart_add',
330
332
'bzrlib.selftest.testdiff',
331
# 'bzrlib.selftest.test_parent',
332
333
'bzrlib.selftest.test_xml',
333
# 'bzrlib.selftest.testfetch',
334
# 'bzrlib.selftest.whitebox',
335
335
'bzrlib.selftest.teststore',
336
# 'bzrlib.selftest.blackbox',
336
'bzrlib.selftest.testgraph',
339
339
for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,