~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Robert Collins
  • Date: 2006-05-16 05:16:22 UTC
  • mto: (1713.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1714.
  • Revision ID: robertc@robertcollins.net-20060516051622-807a8bbda673f4ee
'bzr selftest --benchmark' will run a new benchmarking selftest.
(Robert Collins, Martin Pool).

Show diffs side-by-side

added added

removed removed

Lines of Context:
348
348
    accidentally overlooked.
349
349
    """
350
350
 
351
 
    BZRPATH = 'bzr'
352
351
    _log_file_name = None
353
352
    _log_contents = ''
354
353
 
1018
1017
 
1019
1018
def selftest(verbose=False, pattern=".*", stop_on_failure=True,
1020
1019
             keep_output=False,
1021
 
             transport=None):
 
1020
             transport=None,
 
1021
             test_suite_factory=None):
1022
1022
    """Run the whole test suite under the enhanced runner"""
1023
1023
    global default_transport
1024
1024
    if transport is None:
1025
1025
        transport = default_transport
1026
1026
    old_transport = default_transport
1027
1027
    default_transport = transport
1028
 
    suite = test_suite()
1029
1028
    try:
 
1029
        if test_suite_factory is None:
 
1030
            suite = test_suite()
 
1031
        else:
 
1032
            suite = test_suite_factory()
1030
1033
        return run_suite(suite, 'testbzr', verbose=verbose, pattern=pattern,
1031
1034
                     stop_on_failure=stop_on_failure, keep_output=keep_output,
1032
1035
                     transport=transport)
1034
1037
        default_transport = old_transport
1035
1038
 
1036
1039
 
 
1040
def benchmark_suite():
 
1041
    """Build and return a TestSuite which contains benchmark tests only."""
 
1042
    return TestSuite()
 
1043
 
1037
1044
 
1038
1045
def test_suite():
1039
 
    """Build and return TestSuite for the whole program."""
 
1046
    """Build and return TestSuite for the whole of bzrlib.
 
1047
    
 
1048
    This function can be replaced if you need to change the default test
 
1049
    suite on a global basis, but it is not encouraged.
 
1050
    """
1040
1051
    from doctest import DocTestSuite
1041
1052
 
1042
1053
    global MODULES_TO_DOCTEST
1114
1125
    test_transport_implementations = [
1115
1126
        'bzrlib.tests.test_transport_implementations']
1116
1127
 
1117
 
    TestCase.BZRPATH = osutils.pathjoin(
1118
 
            osutils.realpath(osutils.dirname(bzrlib.__path__[0])), 'bzr')
1119
 
    print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
1120
 
    print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
1121
 
    print
1122
1128
    suite = TestSuite()
1123
1129
    # python2.4's TestLoader.loadTestsFromNames gives very poor 
1124
1130
    # errors if it fails to load a named module - no indication of what's