bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4797.19.2
by John Arbash Meinel
bring in the latest 2.1 changes |
1 |
# Copyright (C) 2007-2010 Canonical Ltd
|
|
2338.4.6
by Marien Zwart
Move some tests that do not need a working tree from workingtree_implementations to tree_implementations. |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
2338.4.6
by Marien Zwart
Move some tests that do not need a working tree from workingtree_implementations to tree_implementations. |
16 |
|
17 |
"""Tests for interface conformance of inventories of trees."""
|
|
18 |
||
19 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
20 |
from breezy import ( |
|
7122.6.5
by Jelmer Vernooij
More improvements, add tests. |
21 |
osutils, |
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
22 |
tests, |
23 |
)
|
|
|
7122.6.5
by Jelmer Vernooij
More improvements, add tests. |
24 |
from breezy.git.branch import GitBranch |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
25 |
from breezy.tests import ( |
|
4634.131.4
by Martin Pool
test_canonical_tree_name_mismatch needs a case-sensitive filesystem |
26 |
per_tree, |
27 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
28 |
from breezy.mutabletree import MutableTree |
29 |
from breezy.tests import TestSkipped |
|
|
7490.85.1
by Jelmer Vernooij
Factor out PreviewTree. |
30 |
from breezy.transform import PreviewTree |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
31 |
from breezy.tests import ( |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
32 |
features, |
33 |
)
|
|
|
2338.4.6
by Marien Zwart
Move some tests that do not need a working tree from workingtree_implementations to tree_implementations. |
34 |
|
35 |
||
|
6885.6.1
by Jelmer Vernooij
Support specific_files argument to Tree.iter_entries_by_dir. |
36 |
def get_entry(tree, path): |
|
7018.3.10
by Jelmer Vernooij
Consistent return values in PreviewTree.list_files. |
37 |
return next(tree.iter_entries_by_dir(specific_files=[path]))[1] |
|
3363.2.7
by Aaron Bentley
Implement alterntative-to-inventory tests |
38 |
|
39 |
||
|
7122.6.5
by Jelmer Vernooij
More improvements, add tests. |
40 |
class TestSymlinkSupportFunction(per_tree.TestCaseWithTree): |
41 |
||
42 |
def test_supports_symlinks(self): |
|
43 |
self.tree = self.make_branch_and_tree('.') |
|
44 |
self.assertIn(self.tree.supports_symlinks(), [True, False]) |
|
45 |
||
46 |
||
|
7122.4.1
by Jelmer Vernooij
Some refactoring; check for required functionality rather than specific implementation (InventoryTree). |
47 |
class TestTreeWithSymlinks(per_tree.TestCaseWithTree): |
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
48 |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
49 |
_test_needs_features = [features.SymlinkFeature] |
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
50 |
|
51 |
def setUp(self): |
|
|
7122.4.1
by Jelmer Vernooij
Some refactoring; check for required functionality rather than specific implementation (InventoryTree). |
52 |
super(TestTreeWithSymlinks, self).setUp() |
|
2338.4.9
by Marien Zwart
More tests for symlinks in tree inventories. |
53 |
self.tree = self.get_tree_with_subdirs_and_all_content_types() |
54 |
self.tree.lock_read() |
|
55 |
self.addCleanup(self.tree.unlock) |
|
56 |
||
57 |
def test_symlink_target(self): |
|
|
7490.85.1
by Jelmer Vernooij
Factor out PreviewTree. |
58 |
if isinstance(self.tree, (MutableTree, PreviewTree)): |
|
2338.4.9
by Marien Zwart
More tests for symlinks in tree inventories. |
59 |
raise TestSkipped( |
|
3363.3.1
by Aaron Bentley
Combine test_inv_alternatives and test_inv |
60 |
'symlinks not accurately represented in working trees and'
|
61 |
' preview trees') |
|
|
6885.6.1
by Jelmer Vernooij
Support specific_files argument to Tree.iter_entries_by_dir. |
62 |
entry = get_entry(self.tree, 'symlink') |
|
2338.4.9
by Marien Zwart
More tests for symlinks in tree inventories. |
63 |
self.assertEqual(entry.symlink_target, 'link-target') |
64 |
||
|
3363.3.1
by Aaron Bentley
Combine test_inv_alternatives and test_inv |
65 |
def test_symlink_target_tree(self): |
66 |
self.assertEqual('link-target', |
|
67 |
self.tree.get_symlink_target('symlink')) |
|
68 |
||
69 |
def test_kind_symlink(self): |
|
70 |
self.assertEqual('symlink', self.tree.kind('symlink')) |
|
71 |
self.assertIs(None, self.tree.get_file_size('symlink')) |
|
72 |
||
|
2338.4.9
by Marien Zwart
More tests for symlinks in tree inventories. |
73 |
def test_symlink(self): |
|
6885.6.1
by Jelmer Vernooij
Support specific_files argument to Tree.iter_entries_by_dir. |
74 |
entry = get_entry(self.tree, 'symlink') |
|
2338.4.9
by Marien Zwart
More tests for symlinks in tree inventories. |
75 |
self.assertEqual(entry.kind, 'symlink') |
76 |
self.assertEqual(None, entry.text_size) |
|
|
7122.6.5
by Jelmer Vernooij
More improvements, add tests. |
77 |
|
78 |
||
79 |
class TestTreeWithoutSymlinks(per_tree.TestCaseWithTree): |
|
80 |
||
81 |
def setUp(self): |
|
82 |
super(TestTreeWithoutSymlinks, self).setUp() |
|
83 |
self.branch = self.make_branch('a') |
|
84 |
mem_tree = self.branch.create_memorytree() |
|
85 |
with mem_tree.lock_write(): |
|
86 |
mem_tree._file_transport.symlink('source', 'symlink') |
|
87 |
mem_tree.add(['', 'symlink']) |
|
88 |
rev1 = mem_tree.commit('rev1') |
|
89 |
self.assertPathDoesNotExist('a/symlink') |
|
90 |
||
91 |
def test_clone_skips_symlinks(self): |
|
92 |
if isinstance(self.branch, (GitBranch,)): |
|
93 |
# TODO(jelmer): Fix this test for git repositories
|
|
94 |
raise TestSkipped( |
|
95 |
'git trees do not honor osutils.supports_symlinks yet') |
|
96 |
self.overrideAttr(osutils, 'supports_symlinks', lambda p: False) |
|
97 |
# This should not attempt to create any symlinks
|
|
98 |
result_dir = self.branch.controldir.sprout('b') |
|
99 |
result_tree = result_dir.open_workingtree() |
|
100 |
self.assertFalse(result_tree.supports_symlinks()) |
|
101 |
self.assertPathDoesNotExist('b/symlink') |
|
102 |
basis_tree = self.branch.basis_tree() |
|
103 |
self.assertTrue(basis_tree.has_filename('symlink')) |
|
104 |
with result_tree.lock_read(): |
|
105 |
self.assertEqual( |
|
|
7122.6.6
by Jelmer Vernooij
Fix more tests. |
106 |
[('symlink', 'symlink')], |
|
7358.16.1
by Jelmer Vernooij
Don't make TreeChange tuple-like objects anymore, so we can add and remove attributes as necessary. |
107 |
[c.path for c in result_tree.iter_changes(basis_tree)]) |