2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2006 Canonical Ltd
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
16 |
|
17 |
||
18 |
"""InterTree implementation tests for bzr.
|
|
19 |
||
20 |
These test the conformance of all the InterTree variations to the expected API.
|
|
21 |
Specific tests for individual variations are in other places such as:
|
|
22 |
- tests/test_workingtree.py
|
|
23 |
"""
|
|
24 |
||
3696.4.10
by Robert Collins
Basic first cut of full-pyrex iter_changes. |
25 |
import bzrlib |
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
26 |
import bzrlib.errors as errors |
27 |
from bzrlib.transport import get_transport |
|
3363.14.2
by Aaron Bentley
Get iter_changes running to completion |
28 |
from bzrlib.transform import TransformPreview |
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
29 |
from bzrlib.tests import ( |
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
30 |
default_transport, |
31 |
multiply_tests, |
|
32 |
)
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
33 |
from bzrlib.tests.tree_implementations import ( |
34 |
return_parameter, |
|
35 |
revision_tree_from_workingtree, |
|
36 |
TestCaseWithTree, |
|
37 |
)
|
|
38 |
from bzrlib.tree import InterTree |
|
2255.2.164
by Martin Pool
Change the default format for some tests from AB1 back to WorkingTreeFormat3 |
39 |
from bzrlib.workingtree import ( |
40 |
WorkingTreeFormat3, |
|
41 |
)
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
42 |
|
43 |
||
3363.14.9
by Aaron Bentley
Ensure TransformPreview is finalized |
44 |
def return_provided_trees(test_case, source, target): |
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
45 |
"""Return the source and target tree unaltered."""
|
46 |
return source, target |
|
47 |
||
48 |
||
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
49 |
class TestCaseWithTwoTrees(TestCaseWithTree): |
50 |
||
51 |
def make_to_branch_and_tree(self, relpath): |
|
52 |
"""Make a to_workingtree_format branch and tree."""
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
53 |
made_control = self.make_bzrdir(relpath, |
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
54 |
format=self.workingtree_format_to._matchingbzrdir) |
55 |
made_control.create_repository() |
|
56 |
made_control.create_branch() |
|
57 |
return self.workingtree_format_to.initialize(made_control) |
|
58 |
||
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
59 |
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
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 |
||
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
91 |
|
3363.14.9
by Aaron Bentley
Ensure TransformPreview is finalized |
92 |
def mutable_trees_to_preview_trees(test_case, source, target): |
3363.14.2
by Aaron Bentley
Get iter_changes running to completion |
93 |
preview = TransformPreview(target) |
3363.14.9
by Aaron Bentley
Ensure TransformPreview is finalized |
94 |
test_case.addCleanup(preview.finalize) |
3363.14.2
by Aaron Bentley
Get iter_changes running to completion |
95 |
return source, preview.get_preview_tree() |
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
96 |
|
97 |
||
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
98 |
def load_tests(standard_tests, module, loader): |
2255.2.164
by Martin Pool
Change the default format for some tests from AB1 back to WorkingTreeFormat3 |
99 |
default_tree_format = WorkingTreeFormat3() |
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
100 |
submod_tests = loader.loadTestsFromModuleNames([ |
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
101 |
'bzrlib.tests.intertree_implementations.test_compare', |
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
102 |
])
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
103 |
test_intertree_permutations = [ |
104 |
# test InterTree with two default-format working trees.
|
|
3696.4.10
by Robert Collins
Basic first cut of full-pyrex iter_changes. |
105 |
(InterTree.__name__, InterTree, default_tree_format, default_tree_format, |
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
106 |
return_provided_trees)] |
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
107 |
for optimiser in InterTree._optimisers: |
3696.4.10
by Robert Collins
Basic first cut of full-pyrex iter_changes. |
108 |
if optimiser is bzrlib.workingtree_4.InterDirStateTree: |
109 |
# Its a little ugly to be conditional here, but less so than having
|
|
110 |
# the optimiser listed twice.
|
|
111 |
# Add once, compiled version
|
|
112 |
test_intertree_permutations.append( |
|
113 |
(optimiser.__name__ + "(C)", |
|
114 |
optimiser, |
|
115 |
optimiser._matching_from_tree_format, |
|
116 |
optimiser._matching_to_tree_format, |
|
117 |
optimiser.make_source_parent_tree_compiled_dirstate)) |
|
118 |
# python version
|
|
119 |
test_intertree_permutations.append( |
|
120 |
(optimiser.__name__ + "(PY)", |
|
121 |
optimiser, |
|
122 |
optimiser._matching_from_tree_format, |
|
123 |
optimiser._matching_to_tree_format, |
|
124 |
optimiser.make_source_parent_tree_python_dirstate)) |
|
125 |
else: |
|
126 |
test_intertree_permutations.append( |
|
127 |
(optimiser.__name__, |
|
128 |
optimiser, |
|
129 |
optimiser._matching_from_tree_format, |
|
130 |
optimiser._matching_to_tree_format, |
|
131 |
optimiser._test_mutable_trees_to_test_trees)) |
|
3696.4.15
by Robert Collins
Merge bzr.dev. |
132 |
# PreviewTree does not have an InterTree optimiser class.
|
3363.14.2
by Aaron Bentley
Get iter_changes running to completion |
133 |
test_intertree_permutations.append( |
3696.4.15
by Robert Collins
Merge bzr.dev. |
134 |
(InterTree.__name__ + "(PreviewTree)", |
135 |
InterTree, |
|
3363.14.2
by Aaron Bentley
Get iter_changes running to completion |
136 |
default_tree_format, |
137 |
default_tree_format, |
|
138 |
mutable_trees_to_preview_trees)) |
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
139 |
scenarios = make_scenarios( |
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
140 |
default_transport, |
141 |
# None here will cause a readonly decorator to be created
|
|
142 |
# by the TestCaseWithTransport.get_readonly_transport method.
|
|
143 |
None, |
|
144 |
test_intertree_permutations) |
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
145 |
# add the tests for the sub modules to the standard tests.
|
146 |
return multiply_tests(submod_tests, scenarios, standard_tests) |