/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4988.10.5 by John Arbash Meinel
Merge bzr.dev 5021 to resolve NEWS
1
# Copyright (C) 2006-2010 Canonical Ltd
1852.6.7 by Robert Collins
Fix up new tree_implementations __init__.py header.
2
#
1852.6.1 by Robert Collins
Start tree implementation tests.
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.
1852.6.7 by Robert Collins
Fix up new tree_implementations __init__.py header.
7
#
1852.6.1 by Robert Collins
Start tree implementation tests.
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.
1852.6.7 by Robert Collins
Fix up new tree_implementations __init__.py header.
12
#
1852.6.1 by Robert Collins
Start tree implementation tests.
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.6.1 by Robert Collins
Start tree implementation tests.
16
17
18
"""Tree implementation tests for bzr.
19
20
These test the conformance of all the tree variations to the expected API.
21
Specific tests for individual variations are in other places such as:
4523.1.5 by Vincent Ladeuil
Fixed as asked in review.
22
 - tests/per_workingtree/*.py.
1852.6.1 by Robert Collins
Start tree implementation tests.
23
 - tests/test_tree.py
24
 - tests/test_revision.py
25
 - tests/test_workingtree.py
26
"""
27
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
28
from breezy import (
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
29
    errors,
2294.1.1 by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic.
30
    tests,
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
31
    transform,
6437.70.16 by John Arbash Meinel
per_tree re-uses the per_workingtree scenarios.
32
    transport,
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
33
    )
7096.3.1 by Jelmer Vernooij
Run tests against GitRevisionTree.
34
from breezy.git.tree import GitRevisionTree
35
from breezy.git.workingtree import GitWorkingTreeFormat
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
36
from breezy.tests.per_controldir.test_controldir import TestCaseWithControlDir
37
from breezy.tests.per_workingtree import (
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
38
    make_scenarios as wt_make_scenarios,
39
    make_scenario as wt_make_scenario,
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
40
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
41
from breezy.revisiontree import RevisionTree
42
from breezy.transform import TransformPreview
43
from breezy.tests import (
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
44
    features,
45
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
46
from breezy.workingtree import (
5662.3.1 by Jelmer Vernooij
Add WorkingTreeFormatRegistry.
47
    format_registry,
2255.2.164 by Martin Pool
Change the default format for some tests from AB1 back to WorkingTreeFormat3
48
    )
6670.4.1 by Jelmer Vernooij
Update imports.
49
from breezy.bzr.workingtree_4 import (
2255.2.64 by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations'
50
    DirStateRevisionTree,
51
    WorkingTreeFormat4,
3907.2.3 by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced
52
    WorkingTreeFormat5,
2255.2.64 by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations'
53
    )
1852.6.1 by Robert Collins
Start tree implementation tests.
54
55
3363.1.2 by Aaron Bentley
Add TestCase as converter param
56
def return_parameter(testcase, something):
1852.6.1 by Robert Collins
Start tree implementation tests.
57
    """A trivial thunk to return its input."""
58
    return something
59
60
3363.1.2 by Aaron Bentley
Add TestCase as converter param
61
def revision_tree_from_workingtree(testcase, tree):
1852.6.1 by Robert Collins
Start tree implementation tests.
62
    """Create a revision tree from a working tree."""
2100.3.36 by Aaron Bentley
avoid subtree commit when converting a work tree into a revision tree
63
    revid = tree.commit('save tree', allow_pointless=True, recursive=None)
1852.6.1 by Robert Collins
Start tree implementation tests.
64
    return tree.branch.repository.revision_tree(revid)
65
66
3363.1.2 by Aaron Bentley
Add TestCase as converter param
67
def _dirstate_tree_from_workingtree(testcase, tree):
3504.2.1 by John Arbash Meinel
Shortcut iter_references when we know references aren't supported.
68
    revid = tree.commit('save tree', allow_pointless=True, recursive=None)
2255.2.64 by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations'
69
    return tree.basis_tree()
70
71
3363.2.2 by Aaron Bentley
Add PreviewTree pre scenarios
72
def preview_tree_pre(testcase, tree):
73
    tt = TransformPreview(tree)
74
    testcase.addCleanup(tt.finalize)
3363.9.7 by Aaron Bentley
Fix up to use set_parent_ids
75
    preview_tree = tt.get_preview_tree()
76
    preview_tree.set_parent_ids(tree.get_parent_ids())
77
    return preview_tree
3363.2.2 by Aaron Bentley
Add PreviewTree pre scenarios
78
79
3363.10.2 by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios
80
def preview_tree_post(testcase, tree):
3363.10.13 by Aaron Bentley
Preserve past commits when converting to a PreviewTreePost
81
    basis = tree.basis_tree()
82
    tt = TransformPreview(basis)
3363.10.2 by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios
83
    testcase.addCleanup(tt.finalize)
3363.10.5 by Aaron Bentley
Fix locking issue
84
    tree.lock_read()
85
    testcase.addCleanup(tree.unlock)
4961.2.9 by Martin Pool
Rip out most remaining uses of DummyProgressBar
86
    pp = None
87
    transform._prepare_revert_transform(basis, tree, tt, None, False, None,
3363.10.13 by Aaron Bentley
Preserve past commits when converting to a PreviewTreePost
88
                                        basis, {})
3363.10.22 by Aaron Bentley
Fix support for plan_file_merge in PreviewTreePost
89
    preview_tree = tt.get_preview_tree()
90
    preview_tree.set_parent_ids(tree.get_parent_ids())
91
    return preview_tree
3363.10.2 by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios
92
93
4285.2.1 by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests.
94
class TestTreeImplementationSupport(tests.TestCaseWithTransport):
1852.6.1 by Robert Collins
Start tree implementation tests.
95
7096.3.1 by Jelmer Vernooij
Run tests against GitRevisionTree.
96
    def test_revision_tree_from_workingtree_bzr(self):
97
        tree = self.make_branch_and_tree('.', format='bzr')
98
        tree = revision_tree_from_workingtree(self, tree)
99
        self.assertIsInstance(tree, RevisionTree)
100
1852.6.1 by Robert Collins
Start tree implementation tests.
101
    def test_revision_tree_from_workingtree(self):
7096.3.1 by Jelmer Vernooij
Run tests against GitRevisionTree.
102
        tree = self.make_branch_and_tree('.', format='git')
3363.1.3 by Aaron Bentley
Hide workingtree_to_test_tree behind a method, to get bound self
103
        tree = revision_tree_from_workingtree(self, tree)
7096.3.1 by Jelmer Vernooij
Run tests against GitRevisionTree.
104
        self.assertIsInstance(tree, GitRevisionTree)
1852.6.1 by Robert Collins
Start tree implementation tests.
105
106
5363.2.18 by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir.
107
class TestCaseWithTree(TestCaseWithControlDir):
1852.6.1 by Robert Collins
Start tree implementation tests.
108
1852.8.3 by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case.
109
    def make_branch_and_tree(self, relpath):
6437.70.16 by John Arbash Meinel
per_tree re-uses the per_workingtree scenarios.
110
        bzrdir_format = self.workingtree_format.get_controldir_for_branch()
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
111
        made_control = self.make_controldir(relpath, format=bzrdir_format)
1852.6.1 by Robert Collins
Start tree implementation tests.
112
        made_control.create_repository()
6437.70.16 by John Arbash Meinel
per_tree re-uses the per_workingtree scenarios.
113
        b = made_control.create_branch()
6437.70.17 by John Arbash Meinel
Change the attribute lookup, I missed it in the first pass.
114
        if getattr(self, 'repo_is_remote', False):
6437.70.16 by John Arbash Meinel
per_tree re-uses the per_workingtree scenarios.
115
            # If the repo is remote, then we just create a local lightweight
116
            # checkout
117
            # XXX: This duplicates a lot of Branch.create_checkout, but we know
118
            #      we want a) lightweight, and b) a specific WT format. We also
119
            #      know that nothing should already exist, etc.
120
            t = transport.get_transport(relpath)
121
            t.ensure_base()
122
            wt_dir = bzrdir_format.initialize_on_transport(t)
123
            branch_ref = wt_dir.set_branch_reference(b)
124
            wt = wt_dir.create_workingtree(None, from_branch=branch_ref)
125
        else:
126
            wt = self.workingtree_format.initialize(made_control)
127
        return wt
1852.6.1 by Robert Collins
Start tree implementation tests.
128
3363.1.3 by Aaron Bentley
Hide workingtree_to_test_tree behind a method, to get bound self
129
    def workingtree_to_test_tree(self, tree):
130
        return self._workingtree_to_test_tree(self, tree)
131
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
132
    def _convert_tree(self, tree, converter=None):
133
        """helper to convert using the converter or a supplied one."""
134
        # convert that to the final shape
135
        if converter is None:
136
            converter = self.workingtree_to_test_tree
3363.1.3 by Aaron Bentley
Hide workingtree_to_test_tree behind a method, to get bound self
137
        return converter(tree)
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
138
1852.8.3 by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case.
139
    def get_tree_no_parents_no_content(self, empty_tree, converter=None):
140
        """Make a tree with no parents and no contents from empty_tree.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
141
1852.8.3 by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case.
142
        :param empty_tree: A working tree with no content and no parents to
143
            modify.
144
        """
6793.5.1 by Jelmer Vernooij
Hardcode fileids in fewer places.
145
        if empty_tree.supports_setting_file_ids():
6855.3.1 by Jelmer Vernooij
Several more fixes.
146
            empty_tree.set_root_id(b'empty-root-id')
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
147
        return self._convert_tree(empty_tree, converter)
1852.6.1 by Robert Collins
Start tree implementation tests.
148
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
149
    def _make_abc_tree(self, tree):
150
        """setup an abc content tree."""
151
        files = ['a', 'b/', 'b/c']
2255.2.15 by Robert Collins
Dirstate - truncate state file fixing bug in saving a smaller file, get more tree_implementation tests passing.
152
        self.build_tree(files, line_endings='binary',
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
153
                        transport=tree.controldir.root_transport)
6793.5.1 by Jelmer Vernooij
Hardcode fileids in fewer places.
154
        tree.add(files)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
155
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
156
    def get_tree_no_parents_abc_content(self, tree, converter=None):
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
157
        """return a test tree with a, b/, b/c contents."""
158
        self._make_abc_tree(tree)
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
159
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
160
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
161
    def get_tree_no_parents_abc_content_2(self, tree, converter=None):
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
162
        """return a test tree with a, b/, b/c contents.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
163
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
164
        This variation changes the content of 'a' to foobar\n.
165
        """
166
        self._make_abc_tree(tree)
6973.7.5 by Jelmer Vernooij
s/file/open.
167
        with open(tree.basedir + '/a', 'wb') as f:
168
            f.write(b'foobar\n')
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
169
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
170
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
171
    def get_tree_no_parents_abc_content_3(self, tree, converter=None):
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
172
        """return a test tree with a, b/, b/c contents.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
173
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
174
        This variation changes the executable flag of b/c to True.
175
        """
176
        self._make_abc_tree(tree)
7350.3.1 by Jelmer Vernooij
Add Tree.get_transform.
177
        tt = tree.get_transform()
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
178
        trans_id = tt.trans_id_tree_path('b/c')
179
        tt.set_executability(True, trans_id)
180
        tt.apply()
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
181
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
182
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
183
    def get_tree_no_parents_abc_content_4(self, tree, converter=None):
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
184
        """return a test tree with d, b/, b/c contents.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
185
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
186
        This variation renames a to d.
187
        """
188
        self._make_abc_tree(tree)
189
        tree.rename_one('a', 'd')
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
190
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
191
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
192
    def get_tree_no_parents_abc_content_5(self, tree, converter=None):
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
193
        """return a test tree with d, b/, b/c contents.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
194
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
195
        This variation renames a to d and alters its content to 'bar\n'.
196
        """
197
        self._make_abc_tree(tree)
198
        tree.rename_one('a', 'd')
6973.7.5 by Jelmer Vernooij
s/file/open.
199
        with open(tree.basedir + '/d', 'wb') as f:
200
            f.write(b'bar\n')
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
201
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
202
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
203
    def get_tree_no_parents_abc_content_6(self, tree, converter=None):
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
204
        """return a test tree with a, b/, e contents.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
205
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
206
        This variation renames b/c to e, and makes it executable.
207
        """
208
        self._make_abc_tree(tree)
7350.3.1 by Jelmer Vernooij
Add Tree.get_transform.
209
        tt = tree.get_transform()
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
210
        trans_id = tt.trans_id_tree_path('b/c')
211
        parent_trans_id = tt.trans_id_tree_path('')
212
        tt.adjust_path('e', parent_trans_id, trans_id)
213
        tt.set_executability(True, trans_id)
214
        tt.apply()
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
215
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
216
4570.2.3 by Robert Collins
Change the way iter_changes treats specific files to prevent InconsistentDeltas.
217
    def get_tree_no_parents_abc_content_7(self, tree, converter=None):
218
        """return a test tree with a, b/, d/e contents.
219
6973.13.2 by Jelmer Vernooij
Fix some more tests.
220
        This variation adds a dir 'd' (b'd-id'), renames b to d/e.
4570.2.3 by Robert Collins
Change the way iter_changes treats specific files to prevent InconsistentDeltas.
221
        """
222
        self._make_abc_tree(tree)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
223
        self.build_tree(['d/'], transport=tree.controldir.root_transport)
6793.5.1 by Jelmer Vernooij
Hardcode fileids in fewer places.
224
        tree.add(['d'])
7350.3.1 by Jelmer Vernooij
Add Tree.get_transform.
225
        tt = tree.get_transform()
4570.2.3 by Robert Collins
Change the way iter_changes treats specific files to prevent InconsistentDeltas.
226
        trans_id = tt.trans_id_tree_path('b')
227
        parent_trans_id = tt.trans_id_tree_path('d')
228
        tt.adjust_path('e', parent_trans_id, trans_id)
229
        tt.apply()
230
        return self._convert_tree(tree, converter)
231
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
232
    def get_tree_with_subdirs_and_all_content_types(self):
233
        """Return a test tree with subdirs and all content types.
2408.1.3 by Alexander Belchenko
tree_implementations: make usage of symlinks optional
234
        See get_tree_with_subdirs_and_all_supported_content_types for details.
235
        """
2408.1.8 by Alexander Belchenko
forget to return tree
236
        return self.get_tree_with_subdirs_and_all_supported_content_types(True)
2408.1.3 by Alexander Belchenko
tree_implementations: make usage of symlinks optional
237
238
    def get_tree_with_subdirs_and_all_supported_content_types(self, symlinks):
239
        """Return a test tree with subdirs and all supported content types.
240
        Some content types may not be created on some platforms
241
        (like symlinks on native win32)
242
243
        :param  symlinks:   control is symlink should be created in the tree.
244
                            Note: if you wish to automatically set this
245
                            parameters depending on underlying system,
246
                            please use value returned
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
247
                            by breezy.osutils.has_symlinks() function.
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
248
249
        The returned tree has the following inventory:
6851.1.1 by Jelmer Vernooij
More foreign branch fixes.
250
            ['',
251
             '0file',
252
             '1top-dir',
253
             u'2utf\u1234file',
254
             'symlink',            # only if symlinks arg is True
255
             '1top-dir/0file-in-1topdir',
256
             '1top-dir/1dir-in-1topdir']
2408.1.3 by Alexander Belchenko
tree_implementations: make usage of symlinks optional
257
        where each component has the type of its name -
258
        i.e. '1file..' is afile.
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
259
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
260
        note that the order of the paths and fileids is deliberately
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
261
        mismatched to ensure that the result order is path based.
262
        """
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
263
        self.requireFeature(features.UnicodeFilenameFeature)
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
264
        tree = self.make_branch_and_tree('.')
265
        paths = ['0file',
7143.15.2 by Jelmer Vernooij
Run autopep8.
266
                 '1top-dir/',
267
                 u'2utf\u1234file',
268
                 '1top-dir/0file-in-1topdir',
269
                 '1top-dir/1dir-in-1topdir/'
270
                 ]
4285.2.1 by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests.
271
        self.build_tree(paths)
6851.1.1 by Jelmer Vernooij
More foreign branch fixes.
272
        tree.add(paths)
7350.3.1 by Jelmer Vernooij
Add Tree.get_transform.
273
        tt = tree.get_transform()
2408.1.3 by Alexander Belchenko
tree_implementations: make usage of symlinks optional
274
        if symlinks:
275
            root_transaction_id = tt.trans_id_tree_path('')
7045.4.1 by Jelmer Vernooij
Some brz-git fixes.
276
            tt.new_symlink('symlink',
7143.15.2 by Jelmer Vernooij
Run autopep8.
277
                           root_transaction_id, 'link-target', b'symlink')
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
278
        tt.apply()
279
        return self.workingtree_to_test_tree(tree)
280
1852.6.1 by Robert Collins
Start tree implementation tests.
281
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
282
def make_scenarios(transport_server, transport_readonly_server, formats):
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
283
    """Generate test suites for each Tree implementation in breezy.
1852.6.1 by Robert Collins
Start tree implementation tests.
284
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
285
    Currently this covers all working tree formats, and RevisionTree and
286
    DirStateRevisionTree by committing a working tree to create the revision
287
    tree.
1852.6.1 by Robert Collins
Start tree implementation tests.
288
    """
7096.3.1 by Jelmer Vernooij
Run tests against GitRevisionTree.
289
    # TODO(jelmer): Test MemoryTree here
290
    # TODO(jelmer): Test GitMemoryTree here
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
291
    scenarios = wt_make_scenarios(transport_server, transport_readonly_server,
7143.15.2 by Jelmer Vernooij
Run autopep8.
292
                                  formats)
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
293
    # now adjust the scenarios and add the non-working-tree tree scenarios.
294
    for scenario in scenarios:
295
        # for working tree format tests, preserve the tree
296
        scenario[1]["_workingtree_to_test_tree"] = return_parameter
4285.2.1 by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests.
297
    # add RevisionTree scenario
5662.3.1 by Jelmer Vernooij
Add WorkingTreeFormatRegistry.
298
    workingtree_format = format_registry.get_default()
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
299
    scenarios.append((RevisionTree.__name__,
7143.15.2 by Jelmer Vernooij
Run autopep8.
300
                      create_tree_scenario(transport_server, transport_readonly_server,
301
                                           workingtree_format, revision_tree_from_workingtree,)))
7096.3.1 by Jelmer Vernooij
Run tests against GitRevisionTree.
302
    scenarios.append((GitRevisionTree.__name__,
7143.15.2 by Jelmer Vernooij
Run autopep8.
303
                      create_tree_scenario(transport_server, transport_readonly_server,
304
                                           GitWorkingTreeFormat(), revision_tree_from_workingtree,)))
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
305
306
    # also test WorkingTree4/5's RevisionTree implementation which is
307
    # specialised.
308
    # XXX: Ask igc if WT5 revision tree actually is different.
309
    scenarios.append((DirStateRevisionTree.__name__ + ",WT4",
7143.15.2 by Jelmer Vernooij
Run autopep8.
310
                      create_tree_scenario(transport_server, transport_readonly_server,
311
                                           WorkingTreeFormat4(), _dirstate_tree_from_workingtree)))
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
312
    scenarios.append((DirStateRevisionTree.__name__ + ",WT5",
7143.15.2 by Jelmer Vernooij
Run autopep8.
313
                      create_tree_scenario(transport_server, transport_readonly_server,
314
                                           WorkingTreeFormat5(), _dirstate_tree_from_workingtree)))
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
315
    scenarios.append(("PreviewTree", create_tree_scenario(transport_server,
7143.15.2 by Jelmer Vernooij
Run autopep8.
316
                                                          transport_readonly_server, workingtree_format, preview_tree_pre)))
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
317
    scenarios.append(("PreviewTreePost", create_tree_scenario(transport_server,
7143.15.2 by Jelmer Vernooij
Run autopep8.
318
                                                              transport_readonly_server, workingtree_format, preview_tree_post)))
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
319
    return scenarios
320
321
322
def create_tree_scenario(transport_server, transport_readonly_server,
7143.15.2 by Jelmer Vernooij
Run autopep8.
323
                         workingtree_format, converter):
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
324
    """Create a scenario for the specified converter
325
326
    :param converter: A function that converts a workingtree into the
327
        desired format.
328
    :param workingtree_format: The particular workingtree format to
329
        convert from.
330
    :return: a (name, options) tuple, where options is a dict of values
331
        to be used as members of the TestCase.
332
    """
4285.2.1 by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests.
333
    scenario_options = wt_make_scenario(transport_server,
334
                                        transport_readonly_server,
335
                                        workingtree_format)
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
336
    scenario_options["_workingtree_to_test_tree"] = converter
337
    return scenario_options
338
339
6625.1.5 by Martin
Drop custom load_tests implementation and use unittest signature
340
def load_tests(loader, standard_tests, pattern):
4523.1.5 by Vincent Ladeuil
Fixed as asked in review.
341
    per_tree_mod_names = [
6968.2.1 by Jelmer Vernooij
Add Tree.archive, which streams an archived version of a tree.
342
        'archive',
4523.1.5 by Vincent Ladeuil
Fixed as asked in review.
343
        'annotate_iter',
5809.3.1 by Aaron Bentley
Switch to iter_entries_by_dir.
344
        'export',
4523.1.5 by Vincent Ladeuil
Fixed as asked in review.
345
        'get_file_mtime',
346
        'get_file_with_stat',
347
        'get_root_id',
348
        'get_symlink_target',
6478.2.1 by Jelmer Vernooij
Accept path element list as argument to Tree.path2id.
349
        'ids',
4523.1.5 by Vincent Ladeuil
Fixed as asked in review.
350
        'iter_search_rules',
5050.57.1 by Aaron Bentley
Make is_executable treat symlinks and directories the same across tree types.
351
        'is_executable',
4523.1.5 by Vincent Ladeuil
Fixed as asked in review.
352
        'list_files',
5200.3.3 by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
353
        'locking',
4523.1.5 by Vincent Ladeuil
Fixed as asked in review.
354
        'path_content_summary',
355
        'revision_tree',
7122.4.1 by Jelmer Vernooij
Some refactoring; check for required functionality rather than specific implementation (InventoryTree).
356
        'symlinks',
4523.1.5 by Vincent Ladeuil
Fixed as asked in review.
357
        'test_trees',
358
        'tree',
359
        'walkdirs',
360
        ]
361
    submod_tests = loader.loadTestsFromModuleNames(
7096.3.1 by Jelmer Vernooij
Run tests against GitRevisionTree.
362
        [__name__ + '.test_' + name
4523.1.5 by Vincent Ladeuil
Fixed as asked in review.
363
         for name in per_tree_mod_names])
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
364
    scenarios = make_scenarios(
4285.2.1 by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests.
365
        tests.default_transport,
1852.6.1 by Robert Collins
Start tree implementation tests.
366
        # None here will cause a readonly decorator to be created
367
        # by the TestCaseWithTransport.get_readonly_transport method.
368
        None,
5662.3.1 by Jelmer Vernooij
Add WorkingTreeFormatRegistry.
369
        format_registry._get_all())
3302.9.27 by Vincent Ladeuil
Fixed as per Ian's review.
370
    # add the tests for the sub modules
4285.2.1 by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests.
371
    return tests.multiply_tests(submod_tests, scenarios, standard_tests)