587
628
def test_suite():
588
629
"""Build and return TestSuite for the whole program."""
589
import bzrlib.store, bzrlib.inventory, bzrlib.branch
590
import bzrlib.osutils, bzrlib.merge3, bzrlib.plugin
591
630
from doctest import DocTestSuite
593
global MODULES_TO_TEST, MODULES_TO_DOCTEST
632
global MODULES_TO_DOCTEST
595
# FIXME: If these fail to load, e.g. because of a syntax error, the
596
# exception is hidden by unittest. Sucks. Should either fix that or
597
# perhaps import them and pass them to unittest as modules.
599
['bzrlib.tests.MetaTestLog',
635
'bzrlib.tests.test_ancestry',
636
'bzrlib.tests.test_annotate',
600
637
'bzrlib.tests.test_api',
601
'bzrlib.tests.test_gpg',
602
'bzrlib.tests.test_identitymap',
603
'bzrlib.tests.test_inv',
604
'bzrlib.tests.test_ancestry',
638
'bzrlib.tests.test_bad_files',
639
'bzrlib.tests.test_branch',
640
'bzrlib.tests.test_command',
605
641
'bzrlib.tests.test_commit',
606
'bzrlib.tests.test_command',
607
642
'bzrlib.tests.test_commit_merge',
608
643
'bzrlib.tests.test_config',
609
'bzrlib.tests.test_merge3',
610
'bzrlib.tests.test_merge',
644
'bzrlib.tests.test_conflicts',
645
'bzrlib.tests.test_diff',
646
'bzrlib.tests.test_fetch',
647
'bzrlib.tests.test_gpg',
648
'bzrlib.tests.test_graph',
611
649
'bzrlib.tests.test_hashcache',
612
'bzrlib.tests.test_status',
650
'bzrlib.tests.test_http',
651
'bzrlib.tests.test_identitymap',
652
'bzrlib.tests.test_inv',
613
653
'bzrlib.tests.test_log',
614
'bzrlib.tests.test_revisionnamespaces',
615
'bzrlib.tests.test_branch',
654
'bzrlib.tests.test_merge',
655
'bzrlib.tests.test_merge3',
656
'bzrlib.tests.test_merge_core',
657
'bzrlib.tests.test_missing',
658
'bzrlib.tests.test_msgeditor',
659
'bzrlib.tests.test_nonascii',
660
'bzrlib.tests.test_options',
661
'bzrlib.tests.test_parent',
662
'bzrlib.tests.test_plugins',
663
'bzrlib.tests.test_remove',
616
664
'bzrlib.tests.test_revision',
617
665
'bzrlib.tests.test_revision_info',
618
'bzrlib.tests.test_merge_core',
666
'bzrlib.tests.test_revisionnamespaces',
667
'bzrlib.tests.test_revprops',
668
'bzrlib.tests.test_reweave',
669
'bzrlib.tests.test_rio',
670
'bzrlib.tests.test_sampler',
671
'bzrlib.tests.test_selftest',
672
'bzrlib.tests.test_setup',
673
'bzrlib.tests.test_sftp',
619
674
'bzrlib.tests.test_smart_add',
620
'bzrlib.tests.test_bad_files',
621
'bzrlib.tests.test_diff',
622
'bzrlib.tests.test_parent',
623
'bzrlib.tests.test_xml',
624
'bzrlib.tests.test_weave',
625
'bzrlib.tests.test_fetch',
626
'bzrlib.tests.test_whitebox',
675
'bzrlib.tests.test_source',
676
'bzrlib.tests.test_status',
627
677
'bzrlib.tests.test_store',
628
'bzrlib.tests.blackbox',
629
'bzrlib.tests.blackbox.versioning',
630
'bzrlib.tests.blackbox.test_bound_branch',
631
'bzrlib.tests.test_sampler',
678
'bzrlib.tests.test_testament',
679
'bzrlib.tests.test_trace',
632
680
'bzrlib.tests.test_transactions',
633
681
'bzrlib.tests.test_transport',
634
'bzrlib.tests.test_sftp',
635
'bzrlib.tests.test_graph',
682
'bzrlib.tests.test_tsort',
683
'bzrlib.tests.test_ui',
684
'bzrlib.tests.test_uncommit',
685
'bzrlib.tests.test_upgrade',
686
'bzrlib.tests.test_weave',
687
'bzrlib.tests.test_whitebox',
636
688
'bzrlib.tests.test_workingtree',
637
'bzrlib.tests.test_upgrade',
638
'bzrlib.tests.test_uncommit',
639
'bzrlib.tests.test_conflicts',
640
'bzrlib.tests.test_testament',
641
'bzrlib.tests.test_annotate',
642
'bzrlib.tests.test_revprops',
643
'bzrlib.tests.test_options',
644
'bzrlib.tests.test_http',
645
'bzrlib.tests.test_nonascii',
646
'bzrlib.tests.test_reweave',
647
'bzrlib.tests.test_tsort',
648
'bzrlib.tests.test_trace',
649
'bzrlib.tests.test_basicio',
689
'bzrlib.tests.test_xml',
652
for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,
653
bzrlib.osutils, bzrlib.commands, bzrlib.merge3,
656
if m not in MODULES_TO_DOCTEST:
657
MODULES_TO_DOCTEST.append(m)
659
TestCase.BZRPATH = os.path.join(os.path.realpath(os.path.dirname(bzrlib.__path__[0])), 'bzr')
660
print '%-30s %s' % ('bzr binary', TestCase.BZRPATH)
692
print '%10s: %s' % ('bzr', os.path.realpath(sys.argv[0]))
693
print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
662
695
suite = TestSuite()
663
suite.addTest(TestLoader().loadTestsFromNames(testmod_names))
696
# python2.4's TestLoader.loadTestsFromNames gives very poor
697
# errors if it fails to load a named module - no indication of what's
698
# actually wrong, just "no such module". We should probably override that
699
# class, but for the moment just load them ourselves. (mbp 20051202)
700
loader = TestLoader()
701
for mod_name in testmod_names:
702
mod = _load_module_by_name(mod_name)
703
suite.addTest(loader.loadTestsFromModule(mod))
704
for package in packages_to_test():
705
suite.addTest(package.test_suite())
664
706
for m in MODULES_TO_TEST:
665
suite.addTest(TestLoader().loadTestsFromModule(m))
707
suite.addTest(loader.loadTestsFromModule(m))
666
708
for m in (MODULES_TO_DOCTEST):
667
709
suite.addTest(DocTestSuite(m))
668
for p in bzrlib.plugin.all_plugins:
669
if hasattr(p, 'test_suite'):
670
suite.addTest(p.test_suite())
710
for name, plugin in bzrlib.plugin.all_plugins().items():
711
if hasattr(plugin, 'test_suite'):
712
suite.addTest(plugin.test_suite())
716
def _load_module_by_name(mod_name):
717
parts = mod_name.split('.')
718
module = __import__(mod_name)
720
# for historical reasons python returns the top-level module even though
721
# it loads the submodule; we need to walk down to get the one we want.
723
module = getattr(module, parts.pop(0))