52
54
class TestCaseWithTwoTrees(TestCaseWithTree):
56
def not_applicable_if_cannot_represent_unversioned(self, tree):
57
if isinstance(tree, revisiontree.RevisionTree):
58
# The locked test trees conversion could not preserve the
59
# unversioned file status. This is normal (e.g. InterDirstateTree
60
# falls back to InterTree if the basis is not a
61
# DirstateRevisionTree, and revision trees cannot have unversioned
63
raise tests.TestNotApplicable('cannot represent unversioned files')
65
def not_applicable_if_missing_in(self, relpath, tree):
66
if not tree.path2id(relpath):
67
# The locked test trees conversion could not preserve the missing
68
# file status. This is normal (e.g. InterDirstateTree falls back
69
# to InterTree if the basis is not a DirstateRevisionTree, and
70
# revision trees cannot have missing files.
71
raise tests.TestNotApplicable('cannot represent missing files')
54
73
def make_to_branch_and_tree(self, relpath):
55
74
"""Make a to_workingtree_format branch and tree."""
56
made_control = self.make_bzrdir(relpath,
75
made_control = self.make_bzrdir(relpath,
57
76
format=self.workingtree_format_to._matchingbzrdir)
58
77
made_control.create_repository()
59
78
made_control.create_branch()
60
79
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)
82
def make_scenarios(transport_server, transport_readonly_server, formats):
83
"""Transform the input formats to a list of scenarios.
85
:param formats: A list of tuples:.
88
workingtree_format_to,
89
mutable_trees_to_test_trees)
92
for (label, intertree_class,
94
workingtree_format_to,
95
mutable_trees_to_test_trees) in formats:
97
"transport_server": transport_server,
98
"transport_readonly_server": transport_readonly_server,
99
"bzrdir_format":workingtree_format._matchingbzrdir,
100
"workingtree_format":workingtree_format,
101
"intertree_class":intertree_class,
102
"workingtree_format_to":workingtree_format_to,
103
# mutable_trees_to_test_trees takes two trees and converts them to,
104
# whatever relationship the optimiser under test requires.,
105
"mutable_trees_to_test_trees":mutable_trees_to_test_trees,
106
# workingtree_to_test_tree is set to disable changing individual,
107
# trees: instead the mutable_trees_to_test_trees helper is used.,
108
"_workingtree_to_test_tree": return_parameter,
110
result.append(scenario)
97
114
def mutable_trees_to_preview_trees(test_case, source, target):
98
115
preview = TransformPreview(target)
99
116
test_case.addCleanup(preview.finalize)
100
117
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)
119
def mutable_trees_to_revision_trees(test_case, source, target):
120
"""Convert both trees to repository based revision trees."""
121
return (revision_tree_from_workingtree(test_case, source),
122
revision_tree_from_workingtree(test_case, target))
125
def load_tests(standard_tests, module, loader):
107
126
default_tree_format = WorkingTreeFormat3()
108
test_intertree_implementations = [
109
'bzrlib.tests.intertree_implementations.test_compare',
127
submod_tests = loader.loadTestsFromModuleNames([
128
'bzrlib.tests.per_intertree.test_compare',
111
130
test_intertree_permutations = [
112
131
# test InterTree with two default-format working trees.
113
(InterTree.__name__, InterTree, default_tree_format, default_tree_format,
132
(InterTree.__name__, InterTree,
133
default_tree_format, default_tree_format,
114
134
return_provided_trees)]
115
135
for optimiser in InterTree._optimisers:
116
if optimiser is bzrlib.workingtree_4.InterDirStateTree:
136
if optimiser is revisiontree.InterCHKRevisionTree:
137
# XXX: we shouldn't use an Intertree object to detect inventories
139
chk_tree_format = WorkingTreeFormat4()
140
chk_tree_format._get_matchingbzrdir = \
141
lambda:bzrlib.bzrdir.format_registry.make_bzrdir(
142
'development6-rich-root')
143
test_intertree_permutations.append(
144
(InterTree.__name__ + "(CHKInventory)",
148
mutable_trees_to_revision_trees))
149
elif optimiser is bzrlib.workingtree_4.InterDirStateTree:
117
150
# Its a little ugly to be conditional here, but less so than having
118
151
# the optimiser listed twice.
119
152
# Add once, compiled version