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