35
35
revision_tree_from_workingtree,
38
from bzrlib.tests.workingtree_implementations import (
39
WorkingTreeTestProviderAdapter,
38
41
from bzrlib.tree import InterTree
39
from bzrlib.workingtree import (WorkingTreeFormat,
40
WorkingTreeTestProviderAdapter,
42
from bzrlib.workingtree import (
47
def return_provided_trees(source, target):
48
"""Return the source and target tree unaltered."""
44
52
class TestCaseWithTwoTrees(TestCaseWithTree):
51
59
made_control.create_branch()
52
60
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
63
class InterTreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
77
64
"""Generate test suites for each InterTree implementation in bzrlib."""
79
def adapt(self, test):
66
def formats_to_scenarios(self, formats):
67
"""Transform the input formats to a list of scenarios.
69
:param formats: A list of tuples:.
72
workingtree_format_to,
73
mutable_trees_to_test_trees)
81
76
for (intertree_class,
82
77
workingtree_format,
83
workingtree_to_test_tree,
84
78
workingtree_format_to,
85
workingtree_to_test_tree_to) in self._formats:
86
new_test = self._clone_test(
88
workingtree_format._matchingbzrdir,
90
intertree_class.__name__)
91
new_test.intertree_class = intertree_class
92
new_test.workingtree_to_test_tree = workingtree_to_test_tree
93
new_test.workingtree_format_to = workingtree_format_to
94
new_test.workingtree_to_test_tree_to = workingtree_to_test_tree_to
95
result.addTest(new_test)
79
mutable_trees_to_test_trees) in formats:
80
scenario = (intertree_class.__name__, {
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,
94
result.append(scenario)
102
101
# load the tests of the infrastructure for these tests
103
102
result.addTests(loader.loadTestsFromModuleNames(['bzrlib.tests.intertree_implementations']))
105
default_tree_format = WorkingTreeFormat.get_default_format()
104
default_tree_format = WorkingTreeFormat3()
106
105
test_intertree_implementations = [
107
106
'bzrlib.tests.intertree_implementations.test_compare',
109
108
test_intertree_permutations = [
110
109
# test InterTree with two default-format working trees.
111
(InterTree, default_tree_format, return_parameter,
112
default_tree_format, return_parameter)]
110
(InterTree, default_tree_format, default_tree_format,
111
return_provided_trees)]
113
112
for optimiser in InterTree._optimisers:
114
113
test_intertree_permutations.append(
116
optimiser._matching_from_tree_format, optimiser._from_tree_converter,
117
optimiser._matching_to_tree_format, optimiser._to_tree_converter))
115
optimiser._matching_from_tree_format,
116
optimiser._matching_to_tree_format,
117
optimiser._test_mutable_trees_to_test_trees))
118
118
adapter = InterTreeTestProviderAdapter(
119
119
default_transport,
120
120
# None here will cause a readonly decorator to be created