~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

- run all selftests by default

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
 
122
122
 
123
123
class TextTestRunner(unittest.TextTestRunner):
 
124
    stop_on_failure = False
124
125
 
125
126
    def _makeResult(self):
126
127
        result = _MyResult(self.stream, self.descriptions, self.verbosity)
127
 
        return EarlyStoppingTestResultAdapter(result)
 
128
        if self.stop_on_failure:
 
129
            result = EarlyStoppingTestResultAdapter(result)
 
130
        return result
128
131
 
129
132
 
130
133
def iter_suite_tests(suite):
436
439
        logging.info('an info message')
437
440
        warning('something looks dodgy...')
438
441
        logging.debug('hello, test is running')
439
 
        ##assert 0
 
442
        assert 0
440
443
 
441
444
 
442
445
def filter_suite_by_re(suite, pattern):
448
451
    return result
449
452
 
450
453
 
451
 
def run_suite(suite, name='test', verbose=False, pattern=".*"):
 
454
def run_suite(suite, name='test', verbose=False, pattern=".*",
 
455
              stop_on_failure=False):
452
456
    TestCaseInTempDir._TEST_NAME = name
453
457
    if verbose:
454
458
        verbosity = 2
457
461
    runner = TextTestRunner(stream=sys.stdout,
458
462
                            descriptions=0,
459
463
                            verbosity=verbosity)
 
464
    runner.stop_on_failure=stop_on_failure
460
465
    if pattern != '.*':
461
466
        suite = filter_suite_by_re(suite, pattern)
462
467
    result = runner.run(suite)
471
476
    return result.wasSuccessful()
472
477
 
473
478
 
474
 
def selftest(verbose=False, pattern=".*"):
 
479
def selftest(verbose=False, pattern=".*", stop_on_failure=True):
475
480
    """Run the whole test suite under the enhanced runner"""
476
 
    return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
 
481
    return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern,
 
482
                     stop_on_failure=stop_on_failure)
477
483
 
478
484
 
479
485
def test_suite():