~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Andrew Bennetts
  • Date: 2008-01-07 12:07:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3194.
  • Revision ID: andrew.bennetts@canonical.com-20080107120712-06hptn3zo84exauj
Make --coverage a global option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
import sys
44
44
import tempfile
45
45
import time
46
 
import trace
47
46
import unittest
48
47
import warnings
49
48
 
2425
2424
              list_only=False,
2426
2425
              random_seed=None,
2427
2426
              exclude_pattern=None,
2428
 
              strict=False,
2429
 
              coverage_dir=None,
2430
 
              ):
 
2427
              strict=False):
2431
2428
    TestCase._gather_lsprof_in_benchmarks = lsprof_timed
2432
2429
    if verbose:
2433
2430
        verbosity = 2
2470
2467
        else:
2471
2468
            suite = order_changer(filter_suite_by_re(suite, pattern))
2472
2469
 
2473
 
    # Activate code coverage.
2474
 
    if coverage_dir is not None:
2475
 
        tracer = trace.Trace(count=1, trace=0)
2476
 
        sys.settrace(tracer.globaltrace)
2477
 
 
2478
2470
    result = runner.run(suite)
2479
2471
 
2480
 
    if coverage_dir is not None:
2481
 
        sys.settrace(None)
2482
 
        results = tracer.results()
2483
 
        results.write_results(show_missing=1, summary=False,
2484
 
                              coverdir=coverage_dir)
2485
 
 
2486
2472
    if strict:
2487
2473
        return result.wasStrictlySuccessful()
2488
2474
 
2499
2485
             random_seed=None,
2500
2486
             exclude_pattern=None,
2501
2487
             strict=False,
2502
 
             coverage_dir=None,
2503
2488
             ):
2504
2489
    """Run the whole test suite under the enhanced runner"""
2505
2490
    # XXX: Very ugly way to do this...
2527
2512
                     list_only=list_only,
2528
2513
                     random_seed=random_seed,
2529
2514
                     exclude_pattern=exclude_pattern,
2530
 
                     strict=strict,
2531
 
                     coverage_dir=coverage_dir)
 
2515
                     strict=strict)
2532
2516
    finally:
2533
2517
        default_transport = old_transport
2534
2518