/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Lukáš Lalinský
  • Date: 2007-12-17 17:28:25 UTC
  • mfrom: (3120 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3123.
  • Revision ID: lalinsky@gmail.com-20071217172825-tr3pqm1mhvs3gwnn
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
 
94
95
                          TestSuite,
95
96
                          TestLoader,
96
97
                          )
 
98
from bzrlib.tests.EncodingAdapter import EncodingTestAdapter
97
99
from bzrlib.tests.treeshape import build_tree_contents
98
100
import bzrlib.version_info_formats.format_custom
99
101
from bzrlib.workingtree import WorkingTree, WorkingTreeFormat2
2047
2049
 
2048
2050
        This doesn't add anything to a branch.
2049
2051
 
 
2052
        :type shape:    list or tuple.
2050
2053
        :param line_endings: Either 'binary' or 'native'
2051
2054
            in binary mode, exact contents are written in native mode, the
2052
2055
            line endings match the default platform endings.
2054
2057
            If the transport is readonly or None, "." is opened automatically.
2055
2058
        :return: None
2056
2059
        """
 
2060
        if type(shape) not in (list, tuple):
 
2061
            raise AssertionError("Parameter 'shape' should be "
 
2062
                "a list or a tuple. Got %r instead" % (shape,))
2057
2063
        # It's OK to just create them using forward slashes on windows.
2058
2064
        if transport is None or transport.is_readonly():
2059
2065
            transport = get_transport(".")
2283
2289
              random_seed=None,
2284
2290
              exclude_pattern=None,
2285
2291
              strict=False,
 
2292
              coverage_dir=None,
2286
2293
              ):
2287
2294
    TestCase._gather_lsprof_in_benchmarks = lsprof_timed
2288
2295
    if verbose:
2320
2327
        else:
2321
2328
            suite = filter_suite_by_re(suite, pattern, exclude_pattern,
2322
2329
                random_order)
 
2330
 
 
2331
    if coverage_dir is not None:
 
2332
        tracer = trace.Trace(count=1, trace=0)
 
2333
        sys.settrace(tracer.globaltrace)
 
2334
 
2323
2335
    result = runner.run(suite)
2324
2336
 
 
2337
    if coverage_dir is not None:
 
2338
        sys.settrace(None)
 
2339
        results = tracer.results()
 
2340
        results.write_results(show_missing=1, summary=False,
 
2341
                              coverdir=coverage_dir)
 
2342
 
2325
2343
    if strict:
2326
2344
        return result.wasStrictlySuccessful()
2327
2345
 
2338
2356
             random_seed=None,
2339
2357
             exclude_pattern=None,
2340
2358
             strict=False,
 
2359
             coverage_dir=None,
2341
2360
             ):
2342
2361
    """Run the whole test suite under the enhanced runner"""
2343
2362
    # XXX: Very ugly way to do this...
2365
2384
                     list_only=list_only,
2366
2385
                     random_seed=random_seed,
2367
2386
                     exclude_pattern=exclude_pattern,
2368
 
                     strict=strict)
 
2387
                     strict=strict,
 
2388
                     coverage_dir=coverage_dir)
2369
2389
    finally:
2370
2390
        default_transport = old_transport
2371
2391
 
2431
2451
                   'bzrlib.tests.test_lockable_files',
2432
2452
                   'bzrlib.tests.test_log',
2433
2453
                   'bzrlib.tests.test_lsprof',
 
2454
                   'bzrlib.tests.test_lru_cache',
2434
2455
                   'bzrlib.tests.test_mail_client',
2435
2456
                   'bzrlib.tests.test_memorytree',
2436
2457
                   'bzrlib.tests.test_merge',
2474
2495
                   'bzrlib.tests.test_store',
2475
2496
                   'bzrlib.tests.test_strace',
2476
2497
                   'bzrlib.tests.test_subsume',
 
2498
                   'bzrlib.tests.test_switch',
2477
2499
                   'bzrlib.tests.test_symbol_versioning',
2478
2500
                   'bzrlib.tests.test_tag',
2479
2501
                   'bzrlib.tests.test_testament',
2512
2534
    from bzrlib.tests.test_transport_implementations import TransportTestProviderAdapter
2513
2535
    adapter = TransportTestProviderAdapter()
2514
2536
    adapt_modules(test_transport_implementations, adapter, loader, suite)
 
2537
    adapt_tests(
 
2538
        ["bzrlib.tests.test_msgeditor.MsgEditorTest."
 
2539
         "test__create_temp_file_with_commit_template_in_unicode_dir"],
 
2540
        EncodingTestAdapter(), loader, suite)
2515
2541
    for package in packages_to_test():
2516
2542
        suite.addTest(package.test_suite())
2517
2543
    for m in MODULES_TO_TEST:
2603
2629
        suite.addTests(adapter.adapt(test))
2604
2630
 
2605
2631
 
 
2632
def adapt_tests(tests_list, adapter, loader, suite):
 
2633
    """Adapt the tests in tests_list using adapter and add to suite."""
 
2634
    for test in tests_list:
 
2635
        suite.addTests(adapter.adapt(loader.loadTestsFromName(test)))
 
2636
 
 
2637
 
2606
2638
def _rmtree_temp_dir(dirname):
2607
2639
    # If LANG=C we probably have created some bogus paths
2608
2640
    # which rmtree(unicode) will fail to delete
2756
2788
        return 'FTPServer'
2757
2789
 
2758
2790
FTPServerFeature = _FTPServerFeature()
 
2791
 
 
2792
 
 
2793
class _CaseInsensitiveFilesystemFeature(Feature):
 
2794
    """Check if underlined filesystem is case-insensitive
 
2795
    (e.g. on Windows, Cygwin, MacOS)
 
2796
    """
 
2797
 
 
2798
    def _probe(self):
 
2799
        if TestCaseWithMemoryTransport.TEST_ROOT is None:
 
2800
            root = osutils.mkdtemp(prefix='testbzr-', suffix='.tmp')
 
2801
            TestCaseWithMemoryTransport.TEST_ROOT = root
 
2802
        else:
 
2803
            root = TestCaseWithMemoryTransport.TEST_ROOT
 
2804
        tdir = osutils.mkdtemp(prefix='case-sensitive-probe-', suffix='',
 
2805
            dir=root)
 
2806
        name_a = osutils.pathjoin(tdir, 'a')
 
2807
        name_A = osutils.pathjoin(tdir, 'A')
 
2808
        os.mkdir(name_a)
 
2809
        result = osutils.isdir(name_A)
 
2810
        _rmtree_temp_dir(tdir)
 
2811
        return result
 
2812
 
 
2813
    def feature_name(self):
 
2814
        return 'case-insensitive filesystem'
 
2815
 
 
2816
CaseInsensitiveFilesystemFeature = _CaseInsensitiveFilesystemFeature()