38
38
from bzrlib.tree import InterTree
39
from bzrlib.workingtree import (WorkingTreeFormat,
40
WorkingTreeTestProviderAdapter,
39
from bzrlib.workingtree import (
41
WorkingTreeTestProviderAdapter,
45
def return_provided_trees(source, target):
46
"""Return the source and target tree unaltered."""
44
50
class TestCaseWithTwoTrees(TestCaseWithTree):
51
57
made_control.create_branch()
52
58
return self.workingtree_format_to.initialize(made_control)
54
def get_to_tree_no_parents_no_content(self, empty_tree):
55
return super(TestCaseWithTwoTrees, self).get_tree_no_parents_no_content(empty_tree, converter=self.workingtree_to_test_tree_to)
57
def get_to_tree_no_parents_abc_content(self, empty_tree):
58
return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content(empty_tree, converter=self.workingtree_to_test_tree_to)
60
def get_to_tree_no_parents_abc_content_2(self, empty_tree):
61
return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_2(empty_tree, converter=self.workingtree_to_test_tree_to)
63
def get_to_tree_no_parents_abc_content_3(self, empty_tree):
64
return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_3(empty_tree, converter=self.workingtree_to_test_tree_to)
66
def get_to_tree_no_parents_abc_content_4(self, empty_tree):
67
return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_4(empty_tree, converter=self.workingtree_to_test_tree_to)
69
def get_to_tree_no_parents_abc_content_5(self, empty_tree):
70
return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_5(empty_tree, converter=self.workingtree_to_test_tree_to)
72
def get_to_tree_no_parents_abc_content_6(self, empty_tree):
73
return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_6(empty_tree, converter=self.workingtree_to_test_tree_to)
76
61
class InterTreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
77
62
"""Generate test suites for each InterTree implementation in bzrlib."""
80
65
result = TestSuite()
81
66
for (intertree_class,
82
67
workingtree_format,
83
workingtree_to_test_tree,
84
68
workingtree_format_to,
85
workingtree_to_test_tree_to) in self._formats:
69
mutable_trees_to_test_trees) in self._formats:
86
70
new_test = self._clone_test(
88
72
workingtree_format._matchingbzrdir,
89
73
workingtree_format,
90
74
intertree_class.__name__)
91
75
new_test.intertree_class = intertree_class
92
new_test.workingtree_to_test_tree = workingtree_to_test_tree
93
76
new_test.workingtree_format_to = workingtree_format_to
94
new_test.workingtree_to_test_tree_to = workingtree_to_test_tree_to
77
# mutable_trees_to_test_trees takes two trees and converts them to
78
# whatever relationship the optimiser under test requires.
79
new_test.mutable_trees_to_test_trees = mutable_trees_to_test_trees
80
# workingtree_to_test_tree is set to disable changing individual
81
# trees: instead the mutable_trees_to_test_trees helper is used.
82
new_test.workingtree_to_test_tree = return_parameter
95
83
result.addTest(new_test)
102
90
# load the tests of the infrastructure for these tests
103
91
result.addTests(loader.loadTestsFromModuleNames(['bzrlib.tests.intertree_implementations']))
105
default_tree_format = WorkingTreeFormat.get_default_format()
93
default_tree_format = WorkingTreeFormat3()
106
94
test_intertree_implementations = [
107
95
'bzrlib.tests.intertree_implementations.test_compare',
109
97
test_intertree_permutations = [
110
98
# test InterTree with two default-format working trees.
111
(InterTree, default_tree_format, return_parameter,
112
default_tree_format, return_parameter)]
99
(InterTree, default_tree_format, default_tree_format,
100
return_provided_trees)]
113
101
for optimiser in InterTree._optimisers:
114
102
test_intertree_permutations.append(
116
optimiser._matching_from_tree_format, optimiser._from_tree_converter,
117
optimiser._matching_to_tree_format, optimiser._to_tree_converter))
104
optimiser._matching_from_tree_format,
105
optimiser._matching_to_tree_format,
106
optimiser._test_mutable_trees_to_test_trees))
118
107
adapter = InterTreeTestProviderAdapter(
119
108
default_transport,
120
109
# None here will cause a readonly decorator to be created