~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_ls.py

  • Committer: Jelmer Vernooij
  • Date: 2008-06-11 18:58:19 UTC
  • mto: (3649.3.2 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 3658.
  • Revision ID: jelmer@samba.org-20080611185819-o4shi1ranh9zh01e
Move ftp transport into separate directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""External tests of 'bzr ls'"""
18
18
 
19
19
import os
20
20
 
21
 
from bzrlib import ignores, osutils
 
21
from bzrlib import ignores
22
22
from bzrlib.tests import TestCaseWithTransport
23
23
 
24
24
 
26
26
 
27
27
    def setUp(self):
28
28
        super(TestLS, self).setUp()
29
 
 
 
29
        
30
30
        # Create a simple branch that can be used in testing
31
31
        ignores._set_user_ignores(['user-ignore'])
32
32
 
36
36
                                 ('a', 'hello\n'),
37
37
                                 ])
38
38
 
39
 
    def ls_equals(self, value, args=None, recursive=True):
 
39
    def ls_equals(self, value, args=None):
40
40
        command = 'ls'
41
41
        if args is not None:
42
42
            command += ' ' + args
43
 
        if recursive:
44
 
            command += ' -R'
45
43
        out, err = self.run_bzr(command)
46
44
        self.assertEqual('', err)
47
45
        self.assertEqualDiff(value, out)
54
52
    def test_ls_basic(self):
55
53
        """Test the abilities of 'bzr ls'"""
56
54
        self.ls_equals('.bzrignore\na\n')
57
 
        self.ls_equals('.bzrignore\na\n', './')
58
55
        self.ls_equals('?        .bzrignore\n'
59
56
                       '?        a\n',
60
57
                       '--verbose')
63
60
                       '--unknown')
64
61
        self.ls_equals('', '--ignored')
65
62
        self.ls_equals('', '--versioned')
66
 
        self.ls_equals('', '-V')
67
63
        self.ls_equals('.bzrignore\n'
68
64
                       'a\n',
69
65
                       '--unknown --ignored --versioned')
70
 
        self.ls_equals('.bzrignore\n'
71
 
                       'a\n',
72
 
                       '--unknown --ignored -V')
73
66
        self.ls_equals('', '--ignored --versioned')
74
 
        self.ls_equals('', '--ignored -V')
75
67
        self.ls_equals('.bzrignore\0a\0', '--null')
76
68
 
77
69
    def test_ls_added(self):
80
72
                       'V        a\n',
81
73
                       '--verbose')
82
74
        self.wt.commit('add')
83
 
 
 
75
        
84
76
        self.build_tree(['subdir/'])
85
77
        self.ls_equals('?        .bzrignore\n'
86
78
                       'V        a\n'
100
92
        self.ls_equals(
101
93
            '.bzrignore                                         \n'
102
94
            'a                                                  a-id\n'
103
 
            'subdir/                                            subdir-id\n',
 
95
            'subdir                                             subdir-id\n', 
104
96
            '--show-ids')
105
97
        self.ls_equals(
106
98
            '?        .bzrignore\n'
107
99
            'V        a                                         a-id\n'
108
 
            'V        subdir/                                   subdir-id\n',
 
100
            'V        subdir/                                   subdir-id\n', 
109
101
            '--show-ids --verbose')
110
102
        self.ls_equals('.bzrignore\0\0'
111
103
                       'a\0a-id\0'
112
104
                       'subdir\0subdir-id\0', '--show-ids --null')
113
105
 
114
 
    def test_ls_no_recursive(self):
 
106
    def test_ls_recursive(self):
115
107
        self.build_tree(['subdir/', 'subdir/b'])
116
108
        self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
117
109
 
118
110
        self.ls_equals('.bzrignore\n'
119
111
                       'a\n'
120
 
                       'subdir/\n'
121
 
                       , recursive=False)
 
112
                       'subdir\n'
 
113
                       , '--non-recursive')
122
114
 
123
115
        self.ls_equals('V        .bzrignore\n'
124
116
                       'V        a\n'
125
117
                       'V        subdir/\n'
126
 
                       , '--verbose', recursive=False)
 
118
                       , '--verbose --non-recursive')
127
119
 
128
120
        # Check what happens in a sub-directory
129
121
        os.chdir('subdir')
130
122
        self.ls_equals('b\n')
131
123
        self.ls_equals('b\0'
132
124
                  , '--null')
133
 
        self.ls_equals('subdir/b\n'
 
125
        self.ls_equals('.bzrignore\n'
 
126
                       'a\n'
 
127
                       'subdir\n'
 
128
                       'subdir/b\n'
134
129
                       , '--from-root')
135
 
        self.ls_equals('subdir/b\0'
 
130
        self.ls_equals('.bzrignore\0'
 
131
                       'a\0'
 
132
                       'subdir\0'
 
133
                       'subdir/b\0'
136
134
                       , '--from-root --null')
137
 
        self.ls_equals('subdir/b\n'
138
 
                       , '--from-root', recursive=False)
 
135
        self.ls_equals('.bzrignore\n'
 
136
                       'a\n'
 
137
                       'subdir\n'
 
138
                       , '--from-root --non-recursive')
139
139
 
140
140
    def test_ls_path(self):
141
141
        """If a path is specified, files are listed with that prefix"""
146
146
        os.chdir('subdir')
147
147
        self.ls_equals('../.bzrignore\n'
148
148
                       '../a\n'
149
 
                       '../subdir/\n'
 
149
                       '../subdir\n'
150
150
                       '../subdir/b\n' ,
151
151
                       '..')
152
152
        self.ls_equals('../.bzrignore\0'
159
159
                       'V        ../subdir/\n'
160
160
                       'V        ../subdir/b\n' ,
161
161
                       '.. --verbose')
162
 
        self.run_bzr_error(['cannot specify both --from-root and PATH'],
 
162
        self.run_bzr_error('cannot specify both --from-root and PATH',
163
163
                           'ls --from-root ..')
164
164
 
165
165
    def test_ls_revision(self):
183
183
        self.wt.commit('committing')
184
184
        branch = self.make_branch('branchdir')
185
185
        branch.pull(self.wt.branch)
186
 
        self.ls_equals('branchdir/subdir/\n'
 
186
        self.ls_equals('branchdir/subdir\n'
187
187
                       'branchdir/subdir/b\n',
188
188
                       'branchdir')
189
 
        self.ls_equals('branchdir/subdir/\n'
 
189
        self.ls_equals('branchdir/subdir\n'
190
190
                       'branchdir/subdir/b\n',
191
191
                       'branchdir --revision 1')
192
192
 
215
215
        self.ls_equals('.bzrignore\n'
216
216
                       'a\n'
217
217
                       , '--versioned')
218
 
        self.ls_equals('.bzrignore\n'
219
 
                       'a\n'
220
 
                       , '-V')
221
218
 
222
219
    def test_kinds(self):
223
220
        self.build_tree(['subdir/'])
224
 
        self.ls_equals('.bzrignore\n'
225
 
                       'a\n',
 
221
        self.ls_equals('.bzrignore\n' 
 
222
                       'a\n', 
226
223
                       '--kind=file')
227
 
        self.ls_equals('subdir/\n',
 
224
        self.ls_equals('subdir\n',
228
225
                       '--kind=directory')
229
226
        self.ls_equals('',
230
227
                       '--kind=symlink')
231
 
        self.run_bzr_error(['invalid kind specified'], 'ls --kind=pile')
232
 
 
233
 
    def test_ls_path_nonrecursive(self):
234
 
        self.ls_equals('%s/.bzrignore\n'
235
 
                       '%s/a\n'
236
 
                       % (self.test_dir, self.test_dir),
237
 
                       self.test_dir, recursive=False)
238
 
 
239
 
    def test_ls_directory(self):
240
 
        """Test --directory option"""
241
 
        self.wt = self.make_branch_and_tree('dir')
242
 
        self.build_tree(['dir/sub/', 'dir/sub/file'])
243
 
        self.wt.add(['sub', 'sub/file'])
244
 
        self.wt.commit('commit')
245
 
        self.ls_equals('sub/\nsub/file\n', '--directory=dir')
246
 
        self.ls_equals('sub/file\n', '-d dir sub')
 
228
        self.run_bzr_error('invalid kind specified', 'ls --kind=pile')