/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
3363.2.7 by Aaron Bentley
Implement alterntative-to-inventory tests
1
# Copyright (C) 2006, 2007, 2008 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:
22
 - tests/test_tree.py
23
 - tests/test_revision.py
24
 - tests/test_workingtree.py
25
 - tests/workingtree_implementations/*.py.
26
"""
27
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
28
from bzrlib import (
29
    errors,
2309.4.10 by John Arbash Meinel
(fixed) Fix the last few tests that were explicitly passing around unicode ids
30
    osutils,
3363.2.17 by Aaron Bentley
Start implementing post-change PreviewTree functionality
31
    progress,
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,
34
    )
1852.6.1 by Robert Collins
Start tree implementation tests.
35
from bzrlib.transport import get_transport
36
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.
37
                          multiply_tests,
1852.6.1 by Robert Collins
Start tree implementation tests.
38
                          default_transport,
39
                          TestCaseWithTransport,
2321.1.2 by Robert Collins
Skip new tests that depend on unicode file paths.
40
                          TestSkipped,
1852.6.1 by Robert Collins
Start tree implementation tests.
41
                          )
42
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
43
from bzrlib.tests.workingtree_implementations import (
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
44
    make_scenarios as wt_make_scenarios,
45
    make_scenario as wt_make_scenario,
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
46
    )
3363.10.2 by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios
47
from bzrlib.revision import NULL_REVISION
2079.1.1 by John Arbash Meinel
Create a deprecated bzrlib.tree.RevisionTree() in favor of bzrlib.revisiontree.RevisionTree()
48
from bzrlib.revisiontree import RevisionTree
3363.2.2 by Aaron Bentley
Add PreviewTree pre scenarios
49
from bzrlib.transform import TransformPreview
2255.2.164 by Martin Pool
Change the default format for some tests from AB1 back to WorkingTreeFormat3
50
from bzrlib.workingtree import (
51
    WorkingTreeFormat,
52
    WorkingTreeFormat3,
53
    _legacy_formats,
54
    )
2255.2.64 by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations'
55
from bzrlib.workingtree_4 import (
56
    DirStateRevisionTree,
57
    WorkingTreeFormat4,
3907.2.3 by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced
58
    WorkingTreeFormat5,
2255.2.64 by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations'
59
    )
1852.6.1 by Robert Collins
Start tree implementation tests.
60
61
3363.1.2 by Aaron Bentley
Add TestCase as converter param
62
def return_parameter(testcase, something):
1852.6.1 by Robert Collins
Start tree implementation tests.
63
    """A trivial thunk to return its input."""
64
    return something
65
66
3363.1.2 by Aaron Bentley
Add TestCase as converter param
67
def revision_tree_from_workingtree(testcase, tree):
1852.6.1 by Robert Collins
Start tree implementation tests.
68
    """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
69
    revid = tree.commit('save tree', allow_pointless=True, recursive=None)
1852.6.1 by Robert Collins
Start tree implementation tests.
70
    return tree.branch.repository.revision_tree(revid)
71
72
3363.1.2 by Aaron Bentley
Add TestCase as converter param
73
def _dirstate_tree_from_workingtree(testcase, tree):
3504.2.1 by John Arbash Meinel
Shortcut iter_references when we know references aren't supported.
74
    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'
75
    return tree.basis_tree()
76
77
3363.2.2 by Aaron Bentley
Add PreviewTree pre scenarios
78
def preview_tree_pre(testcase, tree):
79
    tt = TransformPreview(tree)
80
    testcase.addCleanup(tt.finalize)
3363.9.7 by Aaron Bentley
Fix up to use set_parent_ids
81
    preview_tree = tt.get_preview_tree()
82
    preview_tree.set_parent_ids(tree.get_parent_ids())
83
    return preview_tree
3363.2.2 by Aaron Bentley
Add PreviewTree pre scenarios
84
85
3363.10.2 by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios
86
def preview_tree_post(testcase, tree):
3363.10.13 by Aaron Bentley
Preserve past commits when converting to a PreviewTreePost
87
    basis = tree.basis_tree()
88
    tt = TransformPreview(basis)
3363.10.2 by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios
89
    testcase.addCleanup(tt.finalize)
90
    pp = progress.ProgressPhase('', 1, progress.DummyProgress())
3363.10.5 by Aaron Bentley
Fix locking issue
91
    tree.lock_read()
92
    testcase.addCleanup(tree.unlock)
3363.10.13 by Aaron Bentley
Preserve past commits when converting to a PreviewTreePost
93
    transform._prepare_revert_transform(basis, tree, tt, None, False, pp,
94
                                        basis, {})
3363.10.22 by Aaron Bentley
Fix support for plan_file_merge in PreviewTreePost
95
    preview_tree = tt.get_preview_tree()
96
    preview_tree.set_parent_ids(tree.get_parent_ids())
97
    return preview_tree
3363.10.2 by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios
98
99
1852.6.1 by Robert Collins
Start tree implementation tests.
100
class TestTreeImplementationSupport(TestCaseWithTransport):
101
102
    def test_revision_tree_from_workingtree(self):
103
        tree = self.make_branch_and_tree('.')
3363.1.3 by Aaron Bentley
Hide workingtree_to_test_tree behind a method, to get bound self
104
        tree = revision_tree_from_workingtree(self, tree)
1852.6.1 by Robert Collins
Start tree implementation tests.
105
        self.assertIsInstance(tree, RevisionTree)
106
107
108
class TestCaseWithTree(TestCaseWithBzrDir):
109
1852.8.3 by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case.
110
    def make_branch_and_tree(self, relpath):
111
        made_control = self.make_bzrdir(relpath, format=
112
            self.workingtree_format._matchingbzrdir)
1852.6.1 by Robert Collins
Start tree implementation tests.
113
        made_control.create_repository()
114
        made_control.create_branch()
115
        return self.workingtree_format.initialize(made_control)
116
3363.1.3 by Aaron Bentley
Hide workingtree_to_test_tree behind a method, to get bound self
117
    def workingtree_to_test_tree(self, tree):
118
        return self._workingtree_to_test_tree(self, tree)
119
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
120
    def _convert_tree(self, tree, converter=None):
121
        """helper to convert using the converter or a supplied one."""
122
        # convert that to the final shape
123
        if converter is None:
124
            converter = self.workingtree_to_test_tree
3363.1.3 by Aaron Bentley
Hide workingtree_to_test_tree behind a method, to get bound self
125
        return converter(tree)
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
126
1852.8.3 by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case.
127
    def get_tree_no_parents_no_content(self, empty_tree, converter=None):
128
        """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
129
1852.8.3 by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case.
130
        :param empty_tree: A working tree with no content and no parents to
131
            modify.
132
        """
1731.1.33 by Aaron Bentley
Revert no-special-root changes
133
        empty_tree.set_root_id('empty-root-id')
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
134
        return self._convert_tree(empty_tree, converter)
1852.6.1 by Robert Collins
Start tree implementation tests.
135
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
136
    def _make_abc_tree(self, tree):
137
        """setup an abc content tree."""
138
        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.
139
        self.build_tree(files, line_endings='binary',
1982.1.4 by Alexander Belchenko
tree_implementations tests: build_tree with binary (LF) line-endings
140
                        transport=tree.bzrdir.root_transport)
1731.1.33 by Aaron Bentley
Revert no-special-root changes
141
        tree.set_root_id('root-id')
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
142
        tree.add(files, ['a-id', 'b-id', 'c-id'])
143
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
144
    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.
145
        """return a test tree with a, b/, b/c contents."""
146
        self._make_abc_tree(tree)
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
147
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
148
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
149
    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.
150
        """return a test tree with a, b/, b/c contents.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
151
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
152
        This variation changes the content of 'a' to foobar\n.
153
        """
154
        self._make_abc_tree(tree)
155
        f = open(tree.basedir + '/a', 'wb')
156
        try:
157
            f.write('foobar\n')
158
        finally:
159
            f.close()
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
160
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
161
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
162
    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.
163
        """return a test tree with a, b/, b/c contents.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
164
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
165
        This variation changes the executable flag of b/c to True.
166
        """
167
        self._make_abc_tree(tree)
168
        tt = transform.TreeTransform(tree)
169
        trans_id = tt.trans_id_tree_path('b/c')
170
        tt.set_executability(True, trans_id)
171
        tt.apply()
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_4(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 d, 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 renames a to d.
178
        """
179
        self._make_abc_tree(tree)
180
        tree.rename_one('a', 'd')
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_5(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 and alters its content to 'bar\n'.
187
        """
188
        self._make_abc_tree(tree)
189
        tree.rename_one('a', 'd')
190
        f = open(tree.basedir + '/d', 'wb')
191
        try:
192
            f.write('bar\n')
193
        finally:
194
            f.close()
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
195
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
196
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
197
    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.
198
        """return a test tree with a, b/, e contents.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
199
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
200
        This variation renames b/c to e, and makes it executable.
201
        """
202
        self._make_abc_tree(tree)
203
        tt = transform.TreeTransform(tree)
204
        trans_id = tt.trans_id_tree_path('b/c')
205
        parent_trans_id = tt.trans_id_tree_path('')
206
        tt.adjust_path('e', parent_trans_id, trans_id)
207
        tt.set_executability(True, trans_id)
208
        tt.apply()
1852.8.7 by Robert Collins
Update tree_implementation test tree factories to be intertree ready.
209
        return self._convert_tree(tree, converter)
1852.6.9 by Robert Collins
Add more test trees to the tree-implementations tests.
210
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
211
    def get_tree_with_subdirs_and_all_content_types(self):
212
        """Return a test tree with subdirs and all content types.
2408.1.3 by Alexander Belchenko
tree_implementations: make usage of symlinks optional
213
        See get_tree_with_subdirs_and_all_supported_content_types for details.
214
        """
2408.1.8 by Alexander Belchenko
forget to return tree
215
        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
216
217
    def get_tree_with_subdirs_and_all_supported_content_types(self, symlinks):
218
        """Return a test tree with subdirs and all supported content types.
219
        Some content types may not be created on some platforms
220
        (like symlinks on native win32)
221
222
        :param  symlinks:   control is symlink should be created in the tree.
223
                            Note: if you wish to automatically set this
224
                            parameters depending on underlying system,
225
                            please use value returned
226
                            by bzrlib.osutils.has_symlinks() function.
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
227
228
        The returned tree has the following inventory:
229
            [('', inventory.ROOT_ID),
230
             ('0file', '2file'),
231
             ('1top-dir', '1top-dir'),
232
             (u'2utf\u1234file', u'0utf\u1234file'),
2408.1.3 by Alexander Belchenko
tree_implementations: make usage of symlinks optional
233
             ('symlink', 'symlink'),            # only if symlinks arg is True
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
234
             ('1top-dir/0file-in-1topdir', '1file-in-1topdir'),
235
             ('1top-dir/1dir-in-1topdir', '0dir-in-1topdir')]
2408.1.3 by Alexander Belchenko
tree_implementations: make usage of symlinks optional
236
        where each component has the type of its name -
237
        i.e. '1file..' is afile.
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
238
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
239
        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.
240
        mismatched to ensure that the result order is path based.
241
        """
242
        tree = self.make_branch_and_tree('.')
243
        paths = ['0file',
244
            '1top-dir/',
245
            u'2utf\u1234file',
246
            '1top-dir/0file-in-1topdir',
247
            '1top-dir/1dir-in-1topdir/'
248
            ]
249
        ids = [
250
            '2file',
251
            '1top-dir',
2255.2.107 by John Arbash Meinel
(working), fix dirstate to use utf8 file ids.
252
            u'0utf\u1234file'.encode('utf8'),
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
253
            '1file-in-1topdir',
254
            '0dir-in-1topdir'
255
            ]
2321.1.2 by Robert Collins
Skip new tests that depend on unicode file paths.
256
        try:
257
            self.build_tree(paths)
258
        except UnicodeError:
259
            raise TestSkipped(
260
                'This platform does not support unicode file paths.')
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
261
        tree.add(paths, ids)
262
        tt = transform.TreeTransform(tree)
2408.1.3 by Alexander Belchenko
tree_implementations: make usage of symlinks optional
263
        if symlinks:
264
            root_transaction_id = tt.trans_id_tree_path('')
265
            tt.new_symlink('symlink',
266
                root_transaction_id, 'link-target', 'symlink')
1852.15.1 by Robert Collins
Add a complex test tree for use with Tree.walkdirs.
267
        tt.apply()
268
        return self.workingtree_to_test_tree(tree)
269
2294.1.1 by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic.
270
    def get_tree_with_utf8(self, tree):
271
        """Generate a tree with a utf8 revision and unicode paths."""
2294.1.2 by John Arbash Meinel
Track down and add tests that all tree.commit() can handle
272
        self._create_tree_with_utf8(tree)
273
        return self.workingtree_to_test_tree(tree)
274
275
    def _create_tree_with_utf8(self, tree):
276
        """Generate a tree with a utf8 revision and unicode paths."""
3638.3.11 by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test
277
        # We avoid combining characters in file names here, normalization
278
        # checks (as performed by some file systems (OSX) are outside the scope
279
        # of these tests).  We use the euro sign \N{Euro Sign} or \u20ac in
280
        # unicode strings or '\xe2\x82\ac' (its utf-8 encoding) in raw strings.
2294.1.3 by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed.
281
        paths = [u'',
3638.3.11 by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test
282
                 u'fo\N{Euro Sign}o',
283
                 u'ba\N{Euro Sign}r/',
284
                 u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
2294.1.1 by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic.
285
                ]
286
        # bzr itself does not create unicode file ids, but we want them for
287
        # testing.
2309.4.10 by John Arbash Meinel
(fixed) Fix the last few tests that were explicitly passing around unicode ids
288
        file_ids = ['TREE_ROOT',
3638.3.11 by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test
289
                    'fo\xe2\x82\xaco-id',
290
                    'ba\xe2\x82\xacr-id',
291
                    'ba\xe2\x82\xacz-id',
2294.1.1 by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic.
292
                   ]
293
        try:
2294.1.3 by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed.
294
            self.build_tree(paths[1:])
2294.1.1 by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic.
295
        except UnicodeError:
296
            raise tests.TestSkipped('filesystem does not support unicode.')
2946.3.3 by John Arbash Meinel
Prefer tree.get_root_id() as more explicit than tree.path2id('')
297
        if tree.get_root_id() is None:
2255.2.107 by John Arbash Meinel
(working), fix dirstate to use utf8 file ids.
298
            # Some trees do not have a root yet.
299
            tree.add(paths, file_ids)
300
        else:
301
            # Some trees will already have a root
302
            tree.set_root_id(file_ids[0])
303
            tree.add(paths[1:], file_ids[1:])
2294.1.1 by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic.
304
        try:
305
            tree.commit(u'in\xedtial', rev_id=u'r\xe9v-1'.encode('utf8'))
306
        except errors.NonAsciiRevisionId:
307
            raise tests.TestSkipped('non-ascii revision ids not supported')
2294.1.2 by John Arbash Meinel
Track down and add tests that all tree.commit() can handle
308
309
    def get_tree_with_merged_utf8(self, tree):
310
        """Generate a tree with utf8 ancestors."""
311
        self._create_tree_with_utf8(tree)
312
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
3638.3.11 by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test
313
        self.build_tree([u'tree2/ba\N{Euro Sign}r/qu\N{Euro Sign}x'])
314
        tree2.add([u'ba\N{Euro Sign}r/qu\N{Euro Sign}x'],
315
                  [u'qu\N{Euro Sign}x-id'.encode('utf-8')])
2294.1.2 by John Arbash Meinel
Track down and add tests that all tree.commit() can handle
316
        tree2.commit(u'to m\xe9rge', rev_id=u'r\xe9v-2'.encode('utf8'))
317
318
        tree.merge_from_branch(tree2.branch)
319
        tree.commit(u'm\xe9rge', rev_id=u'r\xe9v-3'.encode('utf8'))
2294.1.1 by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic.
320
        return self.workingtree_to_test_tree(tree)
321
1852.6.1 by Robert Collins
Start tree implementation tests.
322
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
323
def make_scenarios(transport_server, transport_readonly_server, formats):
1852.6.1 by Robert Collins
Start tree implementation tests.
324
    """Generate test suites for each Tree implementation in bzrlib.
325
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
326
    Currently this covers all working tree formats, and RevisionTree and
327
    DirStateRevisionTree by committing a working tree to create the revision
328
    tree.
1852.6.1 by Robert Collins
Start tree implementation tests.
329
    """
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
330
    scenarios = wt_make_scenarios(transport_server, transport_readonly_server,
331
        formats)
332
    # now adjust the scenarios and add the non-working-tree tree scenarios.
333
    for scenario in scenarios:
334
        # for working tree format tests, preserve the tree
335
        scenario[1]["_workingtree_to_test_tree"] = return_parameter
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
336
        # add RevisionTree scenario
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
337
    workingtree_format = WorkingTreeFormat._default_format
338
    scenarios.append((RevisionTree.__name__,
339
        create_tree_scenario(transport_server, transport_readonly_server,
340
        workingtree_format, revision_tree_from_workingtree,)))
341
342
    # also test WorkingTree4/5's RevisionTree implementation which is
343
    # specialised.
344
    # XXX: Ask igc if WT5 revision tree actually is different.
345
    scenarios.append((DirStateRevisionTree.__name__ + ",WT4",
346
        create_tree_scenario(transport_server, transport_readonly_server,
347
        WorkingTreeFormat4(), _dirstate_tree_from_workingtree)))
348
    scenarios.append((DirStateRevisionTree.__name__ + ",WT5",
349
        create_tree_scenario(transport_server, transport_readonly_server,
350
        WorkingTreeFormat5(), _dirstate_tree_from_workingtree)))
351
    scenarios.append(("PreviewTree", create_tree_scenario(transport_server,
352
        transport_readonly_server, workingtree_format, preview_tree_pre)))
353
    scenarios.append(("PreviewTreePost", create_tree_scenario(transport_server,
354
        transport_readonly_server, workingtree_format, preview_tree_post)))
355
    return scenarios
356
357
358
def create_tree_scenario(transport_server, transport_readonly_server,
359
    workingtree_format, converter):
360
    """Create a scenario for the specified converter
361
362
    :param name: The name to append to tests using this converter
363
    :param converter: A function that converts a workingtree into the
364
        desired format.
365
    :param workingtree_format: The particular workingtree format to
366
        convert from.
367
    :return: a (name, options) tuple, where options is a dict of values
368
        to be used as members of the TestCase.
369
    """
370
    scenario_options = wt_make_scenario(transport_server, transport_readonly_server,
371
        workingtree_format)
372
    scenario_options["_workingtree_to_test_tree"] = converter
373
    return scenario_options
374
375
376
def load_tests(standard_tests, module, loader):
377
    submod_tests = loader.loadTestsFromModuleNames([
3224.1.28 by John Arbash Meinel
Add some direct tests for Tree.annotate_iter
378
        'bzrlib.tests.tree_implementations.test_annotate_iter',
2255.7.36 by John Arbash Meinel
All trees should implement get_file_mtime()
379
        'bzrlib.tests.tree_implementations.test_get_file_mtime',
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
380
        'bzrlib.tests.tree_implementations.test_get_root_id',
2255.2.134 by John Arbash Meinel
Add a tree-test for get_symlink_target
381
        'bzrlib.tests.tree_implementations.test_get_symlink_target',
2338.4.6 by Marien Zwart
Move some tests that do not need a working tree from workingtree_implementations to tree_implementations.
382
        'bzrlib.tests.tree_implementations.test_inv',
3398.1.24 by Ian Clatworthy
make iter_search_rules a tree method
383
        'bzrlib.tests.tree_implementations.test_iter_search_rules',
2255.2.71 by John Arbash Meinel
Add a test for list_files, and implement it for DirStateRevisionTree
384
        'bzrlib.tests.tree_implementations.test_list_files',
2776.1.7 by Robert Collins
* New method on ``bzrlib.tree.Tree`` ``path_content_summary`` provides a
385
        'bzrlib.tests.tree_implementations.test_path_content_summary',
1908.11.5 by John Arbash Meinel
[merge] bzr.dev 2240
386
        'bzrlib.tests.tree_implementations.test_revision_tree',
1852.6.1 by Robert Collins
Start tree implementation tests.
387
        'bzrlib.tests.tree_implementations.test_test_trees',
1551.9.16 by Aaron Bentley
Implement Tree.annotate_iter for RevisionTree and WorkingTree
388
        'bzrlib.tests.tree_implementations.test_tree',
1852.15.3 by Robert Collins
Add a first-cut Tree.walkdirs method.
389
        'bzrlib.tests.tree_implementations.test_walkdirs',
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
390
        ])
391
    scenarios = make_scenarios(
1852.6.1 by Robert Collins
Start tree implementation tests.
392
        default_transport,
393
        # None here will cause a readonly decorator to be created
394
        # by the TestCaseWithTransport.get_readonly_transport method.
395
        None,
3543.1.1 by Michael Hudson
change the scenario multiplication to get the bzrdir format from the tree and
396
        WorkingTreeFormat._formats.values() + _legacy_formats)
3302.9.27 by Vincent Ladeuil
Fixed as per Ian's review.
397
    # add the tests for the sub modules
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
398
    return multiply_tests(submod_tests, scenarios, standard_tests)