~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Mark Hammond
  • Date: 2008-08-10 11:16:39 UTC
  • mto: (3606.5.3 1.6)
  • mto: This revision was merged to the branch mainline in revision 3626.
  • Revision ID: mhammond@skippinet.com.au-20080810111639-9upz1wig1s8lvz62
install all files with 'restartreplace uninsrestartdelete' and close
tbzrcache at uninstall time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
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')
80
77
                       'V        a\n',
81
78
                       '--verbose')
82
79
        self.wt.commit('add')
83
 
 
 
80
        
84
81
        self.build_tree(['subdir/'])
85
82
        self.ls_equals('?        .bzrignore\n'
86
83
                       'V        a\n'
100
97
        self.ls_equals(
101
98
            '.bzrignore                                         \n'
102
99
            'a                                                  a-id\n'
103
 
            'subdir/                                            subdir-id\n',
 
100
            'subdir                                             subdir-id\n', 
104
101
            '--show-ids')
105
102
        self.ls_equals(
106
103
            '?        .bzrignore\n'
107
104
            'V        a                                         a-id\n'
108
 
            'V        subdir/                                   subdir-id\n',
 
105
            'V        subdir/                                   subdir-id\n', 
109
106
            '--show-ids --verbose')
110
107
        self.ls_equals('.bzrignore\0\0'
111
108
                       'a\0a-id\0'
112
109
                       'subdir\0subdir-id\0', '--show-ids --null')
113
110
 
114
 
    def test_ls_no_recursive(self):
 
111
    def test_ls_recursive(self):
115
112
        self.build_tree(['subdir/', 'subdir/b'])
116
113
        self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
117
114
 
118
115
        self.ls_equals('.bzrignore\n'
119
116
                       'a\n'
120
 
                       'subdir/\n'
121
 
                       , recursive=False)
 
117
                       'subdir\n'
 
118
                       , '--non-recursive')
122
119
 
123
120
        self.ls_equals('V        .bzrignore\n'
124
121
                       'V        a\n'
125
122
                       'V        subdir/\n'
126
 
                       , '--verbose', recursive=False)
 
123
                       , '--verbose --non-recursive')
127
124
 
128
125
        # Check what happens in a sub-directory
129
126
        os.chdir('subdir')
130
127
        self.ls_equals('b\n')
131
128
        self.ls_equals('b\0'
132
129
                  , '--null')
133
 
        self.ls_equals('subdir/b\n'
 
130
        self.ls_equals('.bzrignore\n'
 
131
                       'a\n'
 
132
                       'subdir\n'
 
133
                       'subdir/b\n'
134
134
                       , '--from-root')
135
 
        self.ls_equals('subdir/b\0'
 
135
        self.ls_equals('.bzrignore\0'
 
136
                       'a\0'
 
137
                       'subdir\0'
 
138
                       'subdir/b\0'
136
139
                       , '--from-root --null')
137
 
        self.ls_equals('subdir/b\n'
138
 
                       , '--from-root', recursive=False)
 
140
        self.ls_equals('.bzrignore\n'
 
141
                       'a\n'
 
142
                       'subdir\n'
 
143
                       , '--from-root --non-recursive')
139
144
 
140
145
    def test_ls_path(self):
141
146
        """If a path is specified, files are listed with that prefix"""
146
151
        os.chdir('subdir')
147
152
        self.ls_equals('../.bzrignore\n'
148
153
                       '../a\n'
149
 
                       '../subdir/\n'
 
154
                       '../subdir\n'
150
155
                       '../subdir/b\n' ,
151
156
                       '..')
152
157
        self.ls_equals('../.bzrignore\0'
159
164
                       'V        ../subdir/\n'
160
165
                       'V        ../subdir/b\n' ,
161
166
                       '.. --verbose')
162
 
        self.run_bzr_error(['cannot specify both --from-root and PATH'],
 
167
        self.run_bzr_error('cannot specify both --from-root and PATH',
163
168
                           'ls --from-root ..')
164
169
 
165
170
    def test_ls_revision(self):
183
188
        self.wt.commit('committing')
184
189
        branch = self.make_branch('branchdir')
185
190
        branch.pull(self.wt.branch)
186
 
        self.ls_equals('branchdir/subdir/\n'
 
191
        self.ls_equals('branchdir/subdir\n'
187
192
                       'branchdir/subdir/b\n',
188
193
                       'branchdir')
189
 
        self.ls_equals('branchdir/subdir/\n'
 
194
        self.ls_equals('branchdir/subdir\n'
190
195
                       'branchdir/subdir/b\n',
191
196
                       'branchdir --revision 1')
192
197
 
221
226
 
222
227
    def test_kinds(self):
223
228
        self.build_tree(['subdir/'])
224
 
        self.ls_equals('.bzrignore\n'
225
 
                       'a\n',
 
229
        self.ls_equals('.bzrignore\n' 
 
230
                       'a\n', 
226
231
                       '--kind=file')
227
 
        self.ls_equals('subdir/\n',
 
232
        self.ls_equals('subdir\n',
228
233
                       '--kind=directory')
229
234
        self.ls_equals('',
230
235
                       '--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)
 
236
        self.run_bzr_error('invalid kind specified', 'ls --kind=pile')