97
95
# the beginning, but in an id, the important words are
99
97
SHOW_DESCRIPTIONS = False
100
what = SHOW_DESCRIPTIONS and test.shortDescription()
103
what = what[:62] + '...'
106
if what.startswith('bzrlib.tests.'):
109
what = '...' + what[-62:]
111
self.stream.write('%-65.65s' % what)
99
width = bzrlib.osutils.terminal_width()
100
name_width = width - 15
102
if SHOW_DESCRIPTIONS:
103
what = test.shortDescription()
105
if len(what) > name_width:
106
what = what[:name_width-3] + '...'
109
if what.startswith('bzrlib.tests.'):
111
if len(what) > name_width:
112
what = '...' + what[3-name_width:]
113
what = what.ljust(name_width)
114
self.stream.write(what)
112
115
self.stream.flush()
113
116
self._start_time = time.time()
546
549
def failUnlessExists(self, path):
547
550
"""Fail unless path, which may be abs or relative, exists."""
548
self.failUnless(osutils.lexists(path))
551
self.failUnless(bzrlib.osutils.lexists(path))
550
553
def assertFileEqual(self, content, path):
551
554
"""Fail if path does not contain 'content'."""
552
self.failUnless(osutils.lexists(path))
555
self.failUnless(bzrlib.osutils.lexists(path))
553
556
self.assertEqualDiff(content, open(path, 'r').read())
556
class MetaTestLog(TestCase):
557
def test_logging(self):
558
"""Test logs are captured when a test fails."""
559
self.log('a test message')
560
self._log_file.flush()
561
self.assertContainsRe(self._get_log(), 'a test message\n')
564
559
def filter_suite_by_re(suite, pattern):
565
result = TestUtil.TestSuite()
566
561
filter_re = re.compile(pattern)
567
562
for test in iter_suite_tests(suite):
568
563
if filter_re.search(test.id()):
609
604
global MODULES_TO_DOCTEST
611
# FIXME: If these fail to load, e.g. because of a syntax error, the
612
# exception is hidden by unittest. Sucks. Should either fix that or
613
# perhaps import them and pass them to unittest as modules.
615
['bzrlib.tests.MetaTestLog',
607
'bzrlib.tests.test_ancestry',
616
608
'bzrlib.tests.test_api',
609
'bzrlib.tests.test_bad_files',
617
610
'bzrlib.tests.test_basicio',
618
'bzrlib.tests.test_gpg',
619
'bzrlib.tests.test_identitymap',
620
'bzrlib.tests.test_inv',
621
'bzrlib.tests.test_ancestry',
611
'bzrlib.tests.test_branch',
622
612
'bzrlib.tests.test_commit',
623
613
'bzrlib.tests.test_command',
624
614
'bzrlib.tests.test_commit_merge',
625
615
'bzrlib.tests.test_config',
616
'bzrlib.tests.test_gpg',
617
'bzrlib.tests.test_graph',
618
'bzrlib.tests.test_hashcache',
619
'bzrlib.tests.test_identitymap',
620
'bzrlib.tests.test_inv',
621
'bzrlib.tests.test_log',
626
622
'bzrlib.tests.test_merge3',
627
623
'bzrlib.tests.test_merge',
628
'bzrlib.tests.test_hashcache',
629
'bzrlib.tests.test_status',
630
'bzrlib.tests.test_log',
624
'bzrlib.tests.test_merge_core',
625
'bzrlib.tests.test_msgeditor',
631
626
'bzrlib.tests.test_revisionnamespaces',
632
'bzrlib.tests.test_branch',
633
627
'bzrlib.tests.test_revision',
634
628
'bzrlib.tests.test_revision_info',
635
'bzrlib.tests.test_merge_core',
629
'bzrlib.tests.test_status',
636
630
'bzrlib.tests.test_smart_add',
637
'bzrlib.tests.test_bad_files',
638
631
'bzrlib.tests.test_diff',
639
632
'bzrlib.tests.test_parent',
640
633
'bzrlib.tests.test_xml',
646
639
'bzrlib.tests.test_transactions',
647
640
'bzrlib.tests.test_transport',
648
641
'bzrlib.tests.test_sftp',
649
'bzrlib.tests.test_graph',
650
642
'bzrlib.tests.test_workingtree',
651
643
'bzrlib.tests.test_upgrade',
652
644
'bzrlib.tests.test_uncommit',
645
'bzrlib.tests.test_ui',
653
646
'bzrlib.tests.test_conflicts',
654
'bzrlib.tests.test_testament',
655
647
'bzrlib.tests.test_annotate',
656
'bzrlib.tests.test_revprops',
657
'bzrlib.tests.test_options',
658
648
'bzrlib.tests.test_http',
659
649
'bzrlib.tests.test_nonascii',
650
'bzrlib.tests.test_options',
660
651
'bzrlib.tests.test_plugins',
652
'bzrlib.tests.test_revprops',
661
653
'bzrlib.tests.test_reweave',
654
'bzrlib.tests.test_rio',
655
'bzrlib.tests.test_selftest',
656
'bzrlib.tests.test_testament',
657
'bzrlib.tests.test_trace',
662
658
'bzrlib.tests.test_tsort',
663
'bzrlib.tests.test_trace',
666
TestCase.BZRPATH = os.path.join(os.path.realpath(os.path.dirname(bzrlib.__path__[0])), 'bzr')
667
print '%-30s %s' % ('bzr binary', TestCase.BZRPATH)
661
print '%10s: %s' % ('bzr', os.path.realpath(sys.argv[0]))
662
print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
669
664
suite = TestSuite()
670
suite.addTest(TestLoader().loadTestsFromNames(testmod_names))
665
# python2.4's TestLoader.loadTestsFromNames gives very poor
666
# errors if it fails to load a named module - no indication of what's
667
# actually wrong, just "no such module". We should probably override that
668
# class, but for the moment just load them ourselves. (mbp 20051202)
669
loader = TestLoader()
670
for mod_name in testmod_names:
671
mod = _load_module_by_name(mod_name)
672
suite.addTest(loader.loadTestsFromModule(mod))
671
673
for package in packages_to_test():
672
674
suite.addTest(package.test_suite())
673
675
for m in MODULES_TO_TEST:
674
suite.addTest(TestLoader().loadTestsFromModule(m))
676
suite.addTest(loader.loadTestsFromModule(m))
675
677
for m in (MODULES_TO_DOCTEST):
676
678
suite.addTest(DocTestSuite(m))
677
679
for name, plugin in bzrlib.plugin.all_plugins().items():