60
57
return self.workingtree_format_to.initialize(made_control)
63
class InterTreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
64
"""Generate test suites for each InterTree implementation in bzrlib."""
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)
76
for (label, intertree_class,
78
workingtree_format_to,
79
mutable_trees_to_test_trees) in formats:
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)
60
def make_scenarios(transport_server, transport_readonly_server, formats):
61
"""Transform the input formats to a list of scenarios.
63
:param formats: A list of tuples:.
66
workingtree_format_to,
67
mutable_trees_to_test_trees)
70
for (label, intertree_class,
72
workingtree_format_to,
73
mutable_trees_to_test_trees) in formats:
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,
88
result.append(scenario)
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()
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)
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',
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.
152
144
test_intertree_permutations)
153
# add the tests for the sub modules
154
adapt_modules(test_intertree_implementations, adapter, loader, result)
145
# add the tests for the sub modules to the standard tests.
146
return multiply_tests(submod_tests, scenarios, standard_tests)