bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
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 ( |
30 |
adapt_modules, |
|
31 |
default_transport, |
|
32 |
)
|
|
33 |
from bzrlib.tests.tree_implementations import ( |
|
34 |
return_parameter, |
|
35 |
revision_tree_from_workingtree, |
|
36 |
TestCaseWithTree, |
|
37 |
)
|
|
|
2553.2.10
by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too. |
38 |
from bzrlib.tests.workingtree_implementations import ( |
39 |
WorkingTreeTestProviderAdapter, |
|
40 |
)
|
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
41 |
from bzrlib.tree import InterTree |
|
2255.2.164
by Martin Pool
Change the default format for some tests from AB1 back to WorkingTreeFormat3 |
42 |
from bzrlib.workingtree import ( |
43 |
WorkingTreeFormat3, |
|
44 |
)
|
|
|
3735.2.35
by Robert Collins
Hook in CHKInventory to the intertree tests. |
45 |
from bzrlib.workingtree_4 import WorkingTreeFormat4 |
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
46 |
|
47 |
||
|
3363.14.9
by Aaron Bentley
Ensure TransformPreview is finalized |
48 |
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. |
49 |
"""Return the source and target tree unaltered.""" |
50 |
return source, target |
|
51 |
||
52 |
||
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
53 |
class TestCaseWithTwoTrees(TestCaseWithTree): |
54 |
||
55 |
def make_to_branch_and_tree(self, relpath): |
|
56 |
"""Make a to_workingtree_format branch and tree.""" |
|
|
3735.2.35
by Robert Collins
Hook in CHKInventory to the intertree tests. |
57 |
made_control = self.make_bzrdir(relpath, |
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
58 |
format=self.workingtree_format_to._matchingbzrdir) |
59 |
made_control.create_repository() |
|
60 |
made_control.create_branch() |
|
61 |
return self.workingtree_format_to.initialize(made_control) |
|
62 |
||
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
63 |
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
64 |
class InterTreeTestProviderAdapter(WorkingTreeTestProviderAdapter): |
65 |
"""Generate test suites for each InterTree implementation in bzrlib.""" |
|
66 |
||
|
2553.2.10
by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too. |
67 |
def formats_to_scenarios(self, formats): |
68 |
"""Transform the input formats to a list of scenarios. |
|
69 |
||
70 |
:param formats: A list of tuples:.
|
|
71 |
(intertree_class,
|
|
72 |
workingtree_format,
|
|
73 |
workingtree_format_to,
|
|
74 |
mutable_trees_to_test_trees)
|
|
75 |
"""
|
|
76 |
result = [] |
|
|
3696.4.10
by Robert Collins
Basic first cut of full-pyrex iter_changes. |
77 |
for (label, intertree_class, |
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
78 |
workingtree_format, |
79 |
workingtree_format_to, |
|
|
2553.2.10
by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too. |
80 |
mutable_trees_to_test_trees) in formats: |
|
3696.4.10
by Robert Collins
Basic first cut of full-pyrex iter_changes. |
81 |
scenario = (label, { |
|
2553.2.10
by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too. |
82 |
"transport_server":self._transport_server, |
83 |
"transport_readonly_server":self._transport_readonly_server, |
|
84 |
"bzrdir_format":workingtree_format._matchingbzrdir, |
|
85 |
"workingtree_format":workingtree_format, |
|
86 |
"intertree_class":intertree_class, |
|
87 |
"workingtree_format_to":workingtree_format_to, |
|
88 |
# mutable_trees_to_test_trees takes two trees and converts them to,
|
|
89 |
# whatever relationship the optimiser under test requires.,
|
|
90 |
"mutable_trees_to_test_trees":mutable_trees_to_test_trees, |
|
91 |
# workingtree_to_test_tree is set to disable changing individual,
|
|
92 |
# trees: instead the mutable_trees_to_test_trees helper is used.,
|
|
|
3363.1.6
by Aaron Bentley
Add docs |
93 |
"_workingtree_to_test_tree": return_parameter, |
|
2553.2.10
by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too. |
94 |
})
|
95 |
result.append(scenario) |
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
96 |
return result |
97 |
||
|
3363.14.9
by Aaron Bentley
Ensure TransformPreview is finalized |
98 |
def mutable_trees_to_preview_trees(test_case, source, target): |
|
3363.14.2
by Aaron Bentley
Get iter_changes running to completion |
99 |
preview = TransformPreview(target) |
|
3363.14.9
by Aaron Bentley
Ensure TransformPreview is finalized |
100 |
test_case.addCleanup(preview.finalize) |
|
3363.14.2
by Aaron Bentley
Get iter_changes running to completion |
101 |
return source, preview.get_preview_tree() |
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
102 |
|
|
3735.2.35
by Robert Collins
Hook in CHKInventory to the intertree tests. |
103 |
|
104 |
def mutable_trees_to_revision_trees(test_case, source, target): |
|
105 |
"""Convert both trees to repository based revision trees.""" |
|
106 |
return (revision_tree_from_workingtree(test_case, source), |
|
107 |
revision_tree_from_workingtree(test_case, target)) |
|
108 |
||
109 |
||
|
3302.9.12
by Vincent Ladeuil
bzrlib.tests.intertree_implementations switched from test_suite() |
110 |
def load_tests(basic_tests, module, loader): |
111 |
result = loader.suiteClass() |
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
112 |
# load the tests of the infrastructure for these tests
|
|
3302.9.12
by Vincent Ladeuil
bzrlib.tests.intertree_implementations switched from test_suite() |
113 |
result.addTests(basic_tests) |
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
114 |
|
|
2255.2.164
by Martin Pool
Change the default format for some tests from AB1 back to WorkingTreeFormat3 |
115 |
default_tree_format = WorkingTreeFormat3() |
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
116 |
test_intertree_implementations = [ |
117 |
'bzrlib.tests.intertree_implementations.test_compare', |
|
118 |
]
|
|
119 |
test_intertree_permutations = [ |
|
120 |
# test InterTree with two default-format working trees.
|
|
|
3696.4.10
by Robert Collins
Basic first cut of full-pyrex iter_changes. |
121 |
(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. |
122 |
return_provided_trees)] |
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
123 |
for optimiser in InterTree._optimisers: |
|
3696.4.10
by Robert Collins
Basic first cut of full-pyrex iter_changes. |
124 |
if optimiser is bzrlib.workingtree_4.InterDirStateTree: |
125 |
# Its a little ugly to be conditional here, but less so than having
|
|
126 |
# the optimiser listed twice.
|
|
127 |
# Add once, compiled version
|
|
128 |
test_intertree_permutations.append( |
|
129 |
(optimiser.__name__ + "(C)", |
|
130 |
optimiser, |
|
131 |
optimiser._matching_from_tree_format, |
|
132 |
optimiser._matching_to_tree_format, |
|
133 |
optimiser.make_source_parent_tree_compiled_dirstate)) |
|
134 |
# python version
|
|
135 |
test_intertree_permutations.append( |
|
136 |
(optimiser.__name__ + "(PY)", |
|
137 |
optimiser, |
|
138 |
optimiser._matching_from_tree_format, |
|
139 |
optimiser._matching_to_tree_format, |
|
140 |
optimiser.make_source_parent_tree_python_dirstate)) |
|
141 |
else: |
|
142 |
test_intertree_permutations.append( |
|
143 |
(optimiser.__name__, |
|
144 |
optimiser, |
|
145 |
optimiser._matching_from_tree_format, |
|
146 |
optimiser._matching_to_tree_format, |
|
147 |
optimiser._test_mutable_trees_to_test_trees)) |
|
|
3696.4.15
by Robert Collins
Merge bzr.dev. |
148 |
# PreviewTree does not have an InterTree optimiser class.
|
|
3363.14.2
by Aaron Bentley
Get iter_changes running to completion |
149 |
test_intertree_permutations.append( |
|
3696.4.15
by Robert Collins
Merge bzr.dev. |
150 |
(InterTree.__name__ + "(PreviewTree)", |
151 |
InterTree, |
|
|
3363.14.2
by Aaron Bentley
Get iter_changes running to completion |
152 |
default_tree_format, |
153 |
default_tree_format, |
|
154 |
mutable_trees_to_preview_trees)) |
|
|
3735.2.35
by Robert Collins
Hook in CHKInventory to the intertree tests. |
155 |
# CHKInventory does not have an InterTree optimiser class (yet).
|
156 |
chk_tree_format = WorkingTreeFormat4() |
|
157 |
chk_tree_format._get_matchingbzrdir = \ |
|
158 |
lambda:bzrlib.bzrdir.format_registry.make_bzrdir('development3') |
|
159 |
test_intertree_permutations.append( |
|
160 |
(InterTree.__name__ + "(CHKInventory)", |
|
161 |
InterTree, |
|
162 |
chk_tree_format, |
|
163 |
chk_tree_format, |
|
164 |
mutable_trees_to_revision_trees)) |
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
165 |
adapter = InterTreeTestProviderAdapter( |
166 |
default_transport, |
|
167 |
# None here will cause a readonly decorator to be created
|
|
168 |
# by the TestCaseWithTransport.get_readonly_transport method.
|
|
169 |
None, |
|
170 |
test_intertree_permutations) |
|
|
3302.9.27
by Vincent Ladeuil
Fixed as per Ian's review. |
171 |
# add the tests for the sub modules
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
172 |
adapt_modules(test_intertree_implementations, adapter, loader, result) |
173 |
return result |