/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/per_tree/test_symlinks.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 01:31:43 UTC
  • mfrom: (7058.6.5 memorytree-symlinks)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304013143-7euyjbmanwo3tpmn
More improvements, add tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
 
20
20
from breezy import (
 
21
    osutils,
21
22
    tests,
22
23
    )
 
24
from breezy.git.branch import GitBranch
23
25
from breezy.tests import (
24
26
    per_tree,
25
27
    )
35
37
    return next(tree.iter_entries_by_dir(specific_files=[path]))[1]
36
38
 
37
39
 
 
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
 
38
47
class TestTreeWithSymlinks(per_tree.TestCaseWithTree):
39
48
 
40
49
    _test_needs_features = [features.SymlinkFeature]
65
74
        entry = get_entry(self.tree, 'symlink')
66
75
        self.assertEqual(entry.kind, 'symlink')
67
76
        self.assertEqual(None, entry.text_size)
 
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
        # Even though 'symlink' does not exist, the tree does not have any delta
 
103
        basis_tree = self.branch.basis_tree()
 
104
        self.assertTrue(basis_tree.has_filename('symlink'))
 
105
        with result_tree.lock_read():
 
106
            self.assertEqual(
 
107
                [],
 
108
                list(result_tree.iter_changes(basis_tree)))