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