~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/intertree_implementations/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2009-03-12 14:02:53 UTC
  • mfrom: (4135 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4137.
  • Revision ID: jelmer@samba.org-20090312140253-bmldbzlmsitfdrzf
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib.transport import get_transport
28
28
from bzrlib.transform import TransformPreview
29
29
from bzrlib.tests import (
30
 
                          adapt_modules,
31
 
                          default_transport,
32
 
                          )
 
30
    default_transport,
 
31
    multiply_tests,
 
32
    )
33
33
from bzrlib.tests.tree_implementations import (
34
34
    return_parameter,
35
35
    revision_tree_from_workingtree,
36
36
    TestCaseWithTree,
37
37
    )
38
 
from bzrlib.tests.workingtree_implementations import (
39
 
    WorkingTreeTestProviderAdapter,
40
 
    )
41
38
from bzrlib.tree import InterTree
42
39
from bzrlib.workingtree import (
43
40
    WorkingTreeFormat3,
60
57
        return self.workingtree_format_to.initialize(made_control)
61
58
 
62
59
 
63
 
class InterTreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
64
 
    """Generate test suites for each InterTree implementation in bzrlib."""
65
 
 
66
 
    def formats_to_scenarios(self, formats):
67
 
        """Transform the input formats to a list of scenarios.
68
 
 
69
 
        :param formats: A list of tuples:.
70
 
            (intertree_class,
71
 
             workingtree_format,
72
 
             workingtree_format_to,
73
 
             mutable_trees_to_test_trees)
74
 
        """
75
 
        result = []
76
 
        for (label, intertree_class,
77
 
            workingtree_format,
78
 
            workingtree_format_to,
79
 
            mutable_trees_to_test_trees) in formats:
80
 
            scenario = (label, {
81
 
                "transport_server":self._transport_server,
82
 
                "transport_readonly_server":self._transport_readonly_server,
83
 
                "bzrdir_format":workingtree_format._matchingbzrdir,
84
 
                "workingtree_format":workingtree_format,
85
 
                "intertree_class":intertree_class,
86
 
                "workingtree_format_to":workingtree_format_to,
87
 
                # mutable_trees_to_test_trees takes two trees and converts them to,
88
 
                # whatever relationship the optimiser under test requires.,
89
 
                "mutable_trees_to_test_trees":mutable_trees_to_test_trees,
90
 
                # workingtree_to_test_tree is set to disable changing individual,
91
 
                # trees: instead the mutable_trees_to_test_trees helper is used.,
92
 
                "_workingtree_to_test_tree": return_parameter,
93
 
                })
94
 
            result.append(scenario)
95
 
        return result
 
60
def make_scenarios(transport_server, transport_readonly_server, formats):
 
61
    """Transform the input formats to a list of scenarios.
 
62
 
 
63
    :param formats: A list of tuples:.
 
64
        (intertree_class,
 
65
         workingtree_format,
 
66
         workingtree_format_to,
 
67
         mutable_trees_to_test_trees)
 
68
    """
 
69
    result = []
 
70
    for (label, intertree_class,
 
71
        workingtree_format,
 
72
        workingtree_format_to,
 
73
        mutable_trees_to_test_trees) in formats:
 
74
        scenario = (label, {
 
75
            "transport_server": transport_server,
 
76
            "transport_readonly_server": transport_readonly_server,
 
77
            "bzrdir_format":workingtree_format._matchingbzrdir,
 
78
            "workingtree_format":workingtree_format,
 
79
            "intertree_class":intertree_class,
 
80
            "workingtree_format_to":workingtree_format_to,
 
81
            # mutable_trees_to_test_trees takes two trees and converts them to,
 
82
            # whatever relationship the optimiser under test requires.,
 
83
            "mutable_trees_to_test_trees":mutable_trees_to_test_trees,
 
84
            # workingtree_to_test_tree is set to disable changing individual,
 
85
            # trees: instead the mutable_trees_to_test_trees helper is used.,
 
86
            "_workingtree_to_test_tree": return_parameter,
 
87
            })
 
88
        result.append(scenario)
 
89
    return result
 
90
 
96
91
 
97
92
def mutable_trees_to_preview_trees(test_case, source, target):
98
93
    preview = TransformPreview(target)
99
94
    test_case.addCleanup(preview.finalize)
100
95
    return source, preview.get_preview_tree()
101
96
 
102
 
def load_tests(basic_tests, module, loader):
103
 
    result = loader.suiteClass()
104
 
    # load the tests of the infrastructure for these tests
105
 
    result.addTests(basic_tests)
106
97
 
 
98
def load_tests(standard_tests, module, loader):
107
99
    default_tree_format = WorkingTreeFormat3()
108
 
    test_intertree_implementations = [
 
100
    submod_tests = loader.loadTestsFromModuleNames([
109
101
        'bzrlib.tests.intertree_implementations.test_compare',
110
 
        ]
 
102
        ])
111
103
    test_intertree_permutations = [
112
104
        # test InterTree with two default-format working trees.
113
105
        (InterTree.__name__, InterTree, default_tree_format, default_tree_format,
144
136
         default_tree_format,
145
137
         default_tree_format,
146
138
         mutable_trees_to_preview_trees))
147
 
    adapter = InterTreeTestProviderAdapter(
 
139
    scenarios = make_scenarios(
148
140
        default_transport,
149
141
        # None here will cause a readonly decorator to be created
150
142
        # by the TestCaseWithTransport.get_readonly_transport method.
151
143
        None,
152
144
        test_intertree_permutations)
153
 
    # add the tests for the sub modules
154
 
    adapt_modules(test_intertree_implementations, adapter, loader, result)
155
 
    return result
 
145
    # add the tests for the sub modules to the standard tests.
 
146
    return multiply_tests(submod_tests, scenarios, standard_tests)