~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
from subprocess import Popen, PIPE
43
43
import sys
44
44
import tempfile
 
45
import time
 
46
import trace
45
47
import unittest
46
 
import time
47
48
import warnings
48
49
 
49
50
 
2286
2287
              random_seed=None,
2287
2288
              exclude_pattern=None,
2288
2289
              strict=False,
 
2290
              coverage_dir=None,
2289
2291
              ):
2290
2292
    TestCase._gather_lsprof_in_benchmarks = lsprof_timed
2291
2293
    if verbose:
2323
2325
        else:
2324
2326
            suite = filter_suite_by_re(suite, pattern, exclude_pattern,
2325
2327
                random_order)
 
2328
 
 
2329
    if coverage_dir is not None:
 
2330
        tracer = trace.Trace(count=1, trace=0)
 
2331
        sys.settrace(tracer.globaltrace)
 
2332
 
2326
2333
    result = runner.run(suite)
2327
2334
 
 
2335
    if coverage_dir is not None:
 
2336
        sys.settrace(None)
 
2337
        results = tracer.results()
 
2338
        results.write_results(show_missing=1, summary=False,
 
2339
                              coverdir=coverage_dir)
 
2340
 
2328
2341
    if strict:
2329
2342
        return result.wasStrictlySuccessful()
2330
2343
 
2341
2354
             random_seed=None,
2342
2355
             exclude_pattern=None,
2343
2356
             strict=False,
 
2357
             coverage_dir=None,
2344
2358
             ):
2345
2359
    """Run the whole test suite under the enhanced runner"""
2346
2360
    # XXX: Very ugly way to do this...
2368
2382
                     list_only=list_only,
2369
2383
                     random_seed=random_seed,
2370
2384
                     exclude_pattern=exclude_pattern,
2371
 
                     strict=strict)
 
2385
                     strict=strict,
 
2386
                     coverage_dir=coverage_dir)
2372
2387
    finally:
2373
2388
        default_transport = old_transport
2374
2389