2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2006 Canonical Ltd
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""External tests of 'bzr ls'"""
|
|
18 |
||
19 |
import os |
|
20 |
||
1551.9.25
by Aaron Bentley
Remove unneeded import |
21 |
from bzrlib import ignores |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
22 |
from bzrlib.tests import TestCaseWithTransport |
23 |
||
24 |
||
25 |
class TestLS(TestCaseWithTransport): |
|
26 |
||
27 |
def setUp(self): |
|
28 |
super(TestLS, self).setUp() |
|
29 |
||
30 |
# Create a simple branch that can be used in testing
|
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
31 |
ignores._set_user_ignores(['user-ignore']) |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
32 |
|
33 |
self.wt = self.make_branch_and_tree('.') |
|
34 |
self.build_tree_contents([ |
|
35 |
('.bzrignore', '*.pyo\n'), |
|
36 |
('a', 'hello\n'), |
|
37 |
])
|
|
38 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
39 |
def ls_equals(self, value, args=None): |
40 |
command = 'ls' |
|
41 |
if args is not None: |
|
42 |
command += ' ' + args |
|
43 |
out, err = self.run_bzr(command) |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
44 |
self.assertEqual('', err) |
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
45 |
self.assertEqualDiff(value, out) |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
46 |
|
47 |
def test_ls_null_verbose(self): |
|
48 |
# Can't supply both
|
|
49 |
self.run_bzr_error(['Cannot set both --verbose and --null'], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
50 |
'ls --verbose --null') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
51 |
|
52 |
def test_ls_basic(self): |
|
53 |
"""Test the abilities of 'bzr ls'"""
|
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
54 |
self.ls_equals('.bzrignore\na\n') |
55 |
self.ls_equals('? .bzrignore\n' |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
56 |
'? a\n', |
57 |
'--verbose') |
|
58 |
self.ls_equals('.bzrignore\n' |
|
59 |
'a\n', |
|
60 |
'--unknown') |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
61 |
self.ls_equals('', '--ignored') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
62 |
self.ls_equals('', '--versioned') |
3382.2.2
by Jerad Cramp
Added tests for 'ls -V'. |
63 |
self.ls_equals('', '-V') |
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
64 |
self.ls_equals('.bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
65 |
'a\n', |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
66 |
'--unknown --ignored --versioned') |
3382.2.2
by Jerad Cramp
Added tests for 'ls -V'. |
67 |
self.ls_equals('.bzrignore\n' |
68 |
'a\n', |
|
69 |
'--unknown --ignored -V') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
70 |
self.ls_equals('', '--ignored --versioned') |
3382.2.2
by Jerad Cramp
Added tests for 'ls -V'. |
71 |
self.ls_equals('', '--ignored -V') |
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
72 |
self.ls_equals('.bzrignore\0a\0', '--null') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
73 |
|
74 |
def test_ls_added(self): |
|
75 |
self.wt.add(['a']) |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
76 |
self.ls_equals('? .bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
77 |
'V a\n', |
78 |
'--verbose') |
|
79 |
self.wt.commit('add') |
|
80 |
||
81 |
self.build_tree(['subdir/']) |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
82 |
self.ls_equals('? .bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
83 |
'V a\n' |
84 |
'? subdir/\n' |
|
85 |
, '--verbose') |
|
86 |
self.build_tree(['subdir/b']) |
|
87 |
self.wt.add(['subdir/', 'subdir/b', '.bzrignore']) |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
88 |
self.ls_equals('V .bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
89 |
'V a\n' |
90 |
'V subdir/\n' |
|
91 |
'V subdir/b\n' |
|
92 |
, '--verbose') |
|
93 |
||
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
94 |
def test_show_ids(self): |
95 |
self.build_tree(['subdir/']) |
|
96 |
self.wt.add(['a', 'subdir'], ['a-id', 'subdir-id']) |
|
97 |
self.ls_equals( |
|
98 |
'.bzrignore \n' |
|
99 |
'a a-id\n' |
|
100 |
'subdir subdir-id\n', |
|
101 |
'--show-ids') |
|
102 |
self.ls_equals( |
|
103 |
'? .bzrignore\n' |
|
104 |
'V a a-id\n' |
|
105 |
'V subdir/ subdir-id\n', |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
106 |
'--show-ids --verbose') |
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
107 |
self.ls_equals('.bzrignore\0\0' |
108 |
'a\0a-id\0' |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
109 |
'subdir\0subdir-id\0', '--show-ids --null') |
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
110 |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
111 |
def test_ls_recursive(self): |
112 |
self.build_tree(['subdir/', 'subdir/b']) |
|
113 |
self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore']) |
|
114 |
||
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
115 |
self.ls_equals('.bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
116 |
'a\n' |
117 |
'subdir\n' |
|
118 |
, '--non-recursive') |
|
119 |
||
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
120 |
self.ls_equals('V .bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
121 |
'V a\n' |
122 |
'V subdir/\n' |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
123 |
, '--verbose --non-recursive') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
124 |
|
125 |
# Check what happens in a sub-directory
|
|
126 |
os.chdir('subdir') |
|
127 |
self.ls_equals('b\n') |
|
128 |
self.ls_equals('b\0' |
|
129 |
, '--null') |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
130 |
self.ls_equals('.bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
131 |
'a\n' |
132 |
'subdir\n' |
|
133 |
'subdir/b\n' |
|
134 |
, '--from-root') |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
135 |
self.ls_equals('.bzrignore\0' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
136 |
'a\0' |
137 |
'subdir\0' |
|
138 |
'subdir/b\0' |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
139 |
, '--from-root --null') |
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
140 |
self.ls_equals('.bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
141 |
'a\n' |
142 |
'subdir\n' |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
143 |
, '--from-root --non-recursive') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
144 |
|
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
145 |
def test_ls_path(self): |
146 |
"""If a path is specified, files are listed with that prefix"""
|
|
147 |
self.build_tree(['subdir/', 'subdir/b']) |
|
148 |
self.wt.add(['subdir', 'subdir/b']) |
|
149 |
self.ls_equals('subdir/b\n' , |
|
150 |
'subdir') |
|
151 |
os.chdir('subdir') |
|
152 |
self.ls_equals('../.bzrignore\n' |
|
153 |
'../a\n' |
|
154 |
'../subdir\n' |
|
155 |
'../subdir/b\n' , |
|
156 |
'..') |
|
157 |
self.ls_equals('../.bzrignore\0' |
|
158 |
'../a\0' |
|
159 |
'../subdir\0' |
|
160 |
'../subdir/b\0' , |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
161 |
'.. --null') |
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
162 |
self.ls_equals('? ../.bzrignore\n' |
163 |
'? ../a\n' |
|
164 |
'V ../subdir/\n' |
|
165 |
'V ../subdir/b\n' , |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
166 |
'.. --verbose') |
167 |
self.run_bzr_error('cannot specify both --from-root and PATH', |
|
168 |
'ls --from-root ..') |
|
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
169 |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
170 |
def test_ls_revision(self): |
171 |
self.wt.add(['a']) |
|
172 |
self.wt.commit('add') |
|
173 |
||
174 |
self.build_tree(['subdir/']) |
|
175 |
||
176 |
# Check what happens when we supply a specific revision
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
177 |
self.ls_equals('a\n', '--revision 1') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
178 |
self.ls_equals('V a\n' |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
179 |
, '--verbose --revision 1') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
180 |
|
181 |
os.chdir('subdir') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
182 |
self.ls_equals('', '--revision 1') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
183 |
|
2215.3.3
by Aaron Bentley
Get ls working on branches |
184 |
def test_ls_branch(self): |
185 |
"""If a branch is specified, files are listed from it"""
|
|
186 |
self.build_tree(['subdir/', 'subdir/b']) |
|
187 |
self.wt.add(['subdir', 'subdir/b']) |
|
188 |
self.wt.commit('committing') |
|
189 |
branch = self.make_branch('branchdir') |
|
190 |
branch.pull(self.wt.branch) |
|
191 |
self.ls_equals('branchdir/subdir\n' |
|
192 |
'branchdir/subdir/b\n', |
|
193 |
'branchdir') |
|
194 |
self.ls_equals('branchdir/subdir\n' |
|
195 |
'branchdir/subdir/b\n', |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
196 |
'branchdir --revision 1') |
2215.3.3
by Aaron Bentley
Get ls working on branches |
197 |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
198 |
def test_ls_ignored(self): |
199 |
# Now try to do ignored files.
|
|
200 |
self.wt.add(['a', '.bzrignore']) |
|
201 |
||
202 |
self.build_tree(['blah.py', 'blah.pyo', 'user-ignore']) |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
203 |
self.ls_equals('.bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
204 |
'a\n' |
205 |
'blah.py\n' |
|
206 |
'blah.pyo\n' |
|
207 |
'user-ignore\n' |
|
208 |
)
|
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
209 |
self.ls_equals('V .bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
210 |
'V a\n' |
211 |
'? blah.py\n' |
|
212 |
'I blah.pyo\n' |
|
213 |
'I user-ignore\n' |
|
214 |
, '--verbose') |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
215 |
self.ls_equals('blah.pyo\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
216 |
'user-ignore\n' |
217 |
, '--ignored') |
|
218 |
self.ls_equals('blah.py\n' |
|
219 |
, '--unknown') |
|
220 |
self.ls_equals('.bzrignore\n' |
|
221 |
'a\n' |
|
222 |
, '--versioned') |
|
3382.2.2
by Jerad Cramp
Added tests for 'ls -V'. |
223 |
self.ls_equals('.bzrignore\n' |
224 |
'a\n' |
|
225 |
, '-V') |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
226 |
|
1551.9.24
by Aaron Bentley
Unhide ls, add kind flag |
227 |
def test_kinds(self): |
228 |
self.build_tree(['subdir/']) |
|
229 |
self.ls_equals('.bzrignore\n' |
|
230 |
'a\n', |
|
231 |
'--kind=file') |
|
232 |
self.ls_equals('subdir\n', |
|
233 |
'--kind=directory') |
|
234 |
self.ls_equals('', |
|
235 |
'--kind=symlink') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
236 |
self.run_bzr_error('invalid kind specified', 'ls --kind=pile') |