bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
1 |
# Copyright (C) 2006-2012 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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
16 |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
17 |
"""External tests of 'brz ls'"""
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
18 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
19 |
from breezy import ( |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
20 |
ignores, |
21 |
tests, |
|
22 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
23 |
from breezy.tests.matchers import ContainsNoVfsCalls |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
24 |
|
25 |
||
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
26 |
class TestLS(tests.TestCaseWithTransport): |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
27 |
|
28 |
def setUp(self): |
|
29 |
super(TestLS, self).setUp() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
30 |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
31 |
# 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 |
32 |
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. |
33 |
|
34 |
self.wt = self.make_branch_and_tree('.') |
|
35 |
self.build_tree_contents([ |
|
36 |
('.bzrignore', '*.pyo\n'), |
|
37 |
('a', 'hello\n'), |
|
38 |
])
|
|
39 |
||
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
40 |
def ls_equals(self, value, args=None, recursive=True, working_dir=None): |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
41 |
command = 'ls' |
42 |
if args is not None: |
|
43 |
command += ' ' + args |
|
4206.2.1
by Ian Clatworthy
ls should be non-recursive by default |
44 |
if recursive: |
45 |
command += ' -R' |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
46 |
out, err = self.run_bzr(command, working_dir=working_dir) |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
47 |
self.assertEqual('', err) |
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
48 |
self.assertEqualDiff(value, out) |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
49 |
|
50 |
def test_ls_null_verbose(self): |
|
51 |
# Can't supply both
|
|
52 |
self.run_bzr_error(['Cannot set both --verbose and --null'], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
53 |
'ls --verbose --null') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
54 |
|
55 |
def test_ls_basic(self): |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
56 |
"""Test the abilities of 'brz ls'""" |
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
57 |
self.ls_equals('.bzrignore\na\n') |
4832.1.1
by Benjamin Peterson
avoid getting extra slashes in the output when ls' argument ends with a slash |
58 |
self.ls_equals('.bzrignore\na\n', './') |
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
59 |
self.ls_equals('? .bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
60 |
'? a\n', |
61 |
'--verbose') |
|
62 |
self.ls_equals('.bzrignore\n' |
|
63 |
'a\n', |
|
64 |
'--unknown') |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
65 |
self.ls_equals('', '--ignored') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
66 |
self.ls_equals('', '--versioned') |
3382.2.2
by Jerad Cramp
Added tests for 'ls -V'. |
67 |
self.ls_equals('', '-V') |
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
68 |
self.ls_equals('.bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
69 |
'a\n', |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
70 |
'--unknown --ignored --versioned') |
3382.2.2
by Jerad Cramp
Added tests for 'ls -V'. |
71 |
self.ls_equals('.bzrignore\n' |
72 |
'a\n', |
|
73 |
'--unknown --ignored -V') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
74 |
self.ls_equals('', '--ignored --versioned') |
3382.2.2
by Jerad Cramp
Added tests for 'ls -V'. |
75 |
self.ls_equals('', '--ignored -V') |
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
76 |
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. |
77 |
|
78 |
def test_ls_added(self): |
|
79 |
self.wt.add(['a']) |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
80 |
self.ls_equals('? .bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
81 |
'V a\n', |
82 |
'--verbose') |
|
83 |
self.wt.commit('add') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
84 |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
85 |
self.build_tree(['subdir/']) |
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
86 |
self.ls_equals('? .bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
87 |
'V a\n' |
88 |
'? subdir/\n' |
|
89 |
, '--verbose') |
|
90 |
self.build_tree(['subdir/b']) |
|
91 |
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 |
92 |
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. |
93 |
'V a\n' |
94 |
'V subdir/\n' |
|
95 |
'V subdir/b\n' |
|
96 |
, '--verbose') |
|
97 |
||
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
98 |
def test_show_ids(self): |
99 |
self.build_tree(['subdir/']) |
|
100 |
self.wt.add(['a', 'subdir'], ['a-id', 'subdir-id']) |
|
101 |
self.ls_equals( |
|
102 |
'.bzrignore \n' |
|
103 |
'a a-id\n' |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
104 |
'subdir/ subdir-id\n', |
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
105 |
'--show-ids') |
106 |
self.ls_equals( |
|
107 |
'? .bzrignore\n' |
|
108 |
'V a a-id\n' |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
109 |
'V subdir/ subdir-id\n', |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
110 |
'--show-ids --verbose') |
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
111 |
self.ls_equals('.bzrignore\0\0' |
112 |
'a\0a-id\0' |
|
3883.1.6
by Gordon P. Hemsley
Revert added slash for null-separated output of 'bzr ls'. |
113 |
'subdir\0subdir-id\0', '--show-ids --null') |
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
114 |
|
4206.2.1
by Ian Clatworthy
ls should be non-recursive by default |
115 |
def test_ls_no_recursive(self): |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
116 |
self.build_tree(['subdir/', 'subdir/b']) |
117 |
self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore']) |
|
118 |
||
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
119 |
self.ls_equals('.bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
120 |
'a\n' |
3883.1.2
by Gordon P. Hemsley
Change unittests to conform to new output. |
121 |
'subdir/\n' |
4206.2.1
by Ian Clatworthy
ls should be non-recursive by default |
122 |
, recursive=False) |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
123 |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
124 |
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. |
125 |
'V a\n' |
126 |
'V subdir/\n' |
|
4206.2.1
by Ian Clatworthy
ls should be non-recursive by default |
127 |
, '--verbose', recursive=False) |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
128 |
|
129 |
# Check what happens in a sub-directory
|
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
130 |
self.ls_equals('b\n', working_dir='subdir') |
131 |
self.ls_equals('b\0', '--null', working_dir='subdir') |
|
132 |
self.ls_equals('subdir/b\n', '--from-root', working_dir='subdir') |
|
133 |
self.ls_equals('subdir/b\0', '--from-root --null', |
|
134 |
working_dir='subdir') |
|
135 |
self.ls_equals('subdir/b\n', '--from-root', recursive=False, |
|
136 |
working_dir='subdir') |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
137 |
|
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
138 |
def test_ls_path(self): |
139 |
"""If a path is specified, files are listed with that prefix""" |
|
140 |
self.build_tree(['subdir/', 'subdir/b']) |
|
141 |
self.wt.add(['subdir', 'subdir/b']) |
|
142 |
self.ls_equals('subdir/b\n' , |
|
143 |
'subdir') |
|
144 |
self.ls_equals('../.bzrignore\n' |
|
145 |
'../a\n' |
|
3883.1.2
by Gordon P. Hemsley
Change unittests to conform to new output. |
146 |
'../subdir/\n' |
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
147 |
'../subdir/b\n' , |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
148 |
'..', working_dir='subdir') |
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
149 |
self.ls_equals('../.bzrignore\0' |
150 |
'../a\0' |
|
3883.1.6
by Gordon P. Hemsley
Revert added slash for null-separated output of 'bzr ls'. |
151 |
'../subdir\0' |
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
152 |
'../subdir/b\0' , |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
153 |
'.. --null', working_dir='subdir') |
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
154 |
self.ls_equals('? ../.bzrignore\n' |
155 |
'? ../a\n' |
|
156 |
'V ../subdir/\n' |
|
157 |
'V ../subdir/b\n' , |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
158 |
'.. --verbose', working_dir='subdir') |
4325.4.6
by Vincent Ladeuil
Fixed as per John's and Markus reviews. |
159 |
self.run_bzr_error(['cannot specify both --from-root and PATH'], |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
160 |
'ls --from-root ..', working_dir='subdir') |
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
161 |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
162 |
def test_ls_revision(self): |
163 |
self.wt.add(['a']) |
|
164 |
self.wt.commit('add') |
|
165 |
||
166 |
self.build_tree(['subdir/']) |
|
167 |
||
168 |
# Check what happens when we supply a specific revision
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
169 |
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. |
170 |
self.ls_equals('V a\n' |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
171 |
, '--verbose --revision 1') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
172 |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
173 |
self.ls_equals('', '--revision 1', working_dir='subdir') |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
174 |
|
2215.3.3
by Aaron Bentley
Get ls working on branches |
175 |
def test_ls_branch(self): |
176 |
"""If a branch is specified, files are listed from it""" |
|
177 |
self.build_tree(['subdir/', 'subdir/b']) |
|
178 |
self.wt.add(['subdir', 'subdir/b']) |
|
179 |
self.wt.commit('committing') |
|
180 |
branch = self.make_branch('branchdir') |
|
181 |
branch.pull(self.wt.branch) |
|
3883.1.2
by Gordon P. Hemsley
Change unittests to conform to new output. |
182 |
self.ls_equals('branchdir/subdir/\n' |
2215.3.3
by Aaron Bentley
Get ls working on branches |
183 |
'branchdir/subdir/b\n', |
184 |
'branchdir') |
|
3883.1.2
by Gordon P. Hemsley
Change unittests to conform to new output. |
185 |
self.ls_equals('branchdir/subdir/\n' |
2215.3.3
by Aaron Bentley
Get ls working on branches |
186 |
'branchdir/subdir/b\n', |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
187 |
'branchdir --revision 1') |
2215.3.3
by Aaron Bentley
Get ls working on branches |
188 |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
189 |
def test_ls_ignored(self): |
190 |
# Now try to do ignored files.
|
|
191 |
self.wt.add(['a', '.bzrignore']) |
|
192 |
||
193 |
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 |
194 |
self.ls_equals('.bzrignore\n' |
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
195 |
'a\n' |
196 |
'blah.py\n' |
|
197 |
'blah.pyo\n' |
|
198 |
'user-ignore\n' |
|
199 |
)
|
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
200 |
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. |
201 |
'V a\n' |
202 |
'? blah.py\n' |
|
203 |
'I blah.pyo\n' |
|
204 |
'I user-ignore\n' |
|
205 |
, '--verbose') |
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
206 |
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. |
207 |
'user-ignore\n' |
208 |
, '--ignored') |
|
209 |
self.ls_equals('blah.py\n' |
|
210 |
, '--unknown') |
|
211 |
self.ls_equals('.bzrignore\n' |
|
212 |
'a\n' |
|
213 |
, '--versioned') |
|
3382.2.2
by Jerad Cramp
Added tests for 'ls -V'. |
214 |
self.ls_equals('.bzrignore\n' |
215 |
'a\n' |
|
216 |
, '-V') |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
217 |
|
1551.9.24
by Aaron Bentley
Unhide ls, add kind flag |
218 |
def test_kinds(self): |
219 |
self.build_tree(['subdir/']) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
220 |
self.ls_equals('.bzrignore\n' |
221 |
'a\n', |
|
1551.9.24
by Aaron Bentley
Unhide ls, add kind flag |
222 |
'--kind=file') |
3883.1.2
by Gordon P. Hemsley
Change unittests to conform to new output. |
223 |
self.ls_equals('subdir/\n', |
1551.9.24
by Aaron Bentley
Unhide ls, add kind flag |
224 |
'--kind=directory') |
225 |
self.ls_equals('', |
|
226 |
'--kind=symlink') |
|
4325.4.6
by Vincent Ladeuil
Fixed as per John's and Markus reviews. |
227 |
self.run_bzr_error(['invalid kind specified'], 'ls --kind=pile') |
4272.1.1
by Jelmer Vernooij
non-recursive bzr ls now works properly when a path is specified. |
228 |
|
229 |
def test_ls_path_nonrecursive(self): |
|
4272.1.2
by Jelmer Vernooij
Fix formatting per Johns comments. |
230 |
self.ls_equals('%s/.bzrignore\n' |
231 |
'%s/a\n' |
|
232 |
% (self.test_dir, self.test_dir), |
|
4272.1.1
by Jelmer Vernooij
non-recursive bzr ls now works properly when a path is specified. |
233 |
self.test_dir, recursive=False) |
5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
234 |
|
235 |
def test_ls_directory(self): |
|
236 |
"""Test --directory option""" |
|
237 |
self.wt = self.make_branch_and_tree('dir') |
|
238 |
self.build_tree(['dir/sub/', 'dir/sub/file']) |
|
239 |
self.wt.add(['sub', 'sub/file']) |
|
240 |
self.wt.commit('commit') |
|
241 |
self.ls_equals('sub/\nsub/file\n', '--directory=dir') |
|
242 |
self.ls_equals('sub/file\n', '-d dir sub') |
|
6283.1.5
by Jelmer Vernooij
Add hpss call count test for 'bzr ls'. |
243 |
|
244 |
||
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
245 |
class TestSmartServerLs(tests.TestCaseWithTransport): |
6283.1.5
by Jelmer Vernooij
Add hpss call count test for 'bzr ls'. |
246 |
|
247 |
def test_simple_ls(self): |
|
248 |
self.setup_smart_server_with_call_log() |
|
249 |
t = self.make_branch_and_tree('branch') |
|
250 |
self.build_tree_contents([('branch/foo', 'thecontents')]) |
|
251 |
t.add("foo") |
|
252 |
t.commit("message") |
|
253 |
self.reset_smart_call_log() |
|
254 |
out, err = self.run_bzr(['ls', self.get_url('branch')]) |
|
255 |
# This figure represent the amount of work to perform this use case. It
|
|
256 |
# is entirely ok to reduce this number if a test fails due to rpc_count
|
|
257 |
# being too low. If rpc_count increases, more network roundtrips have
|
|
258 |
# become necessary for this use case. Please do not adjust this number
|
|
259 |
# upwards without agreement from bzr's network support maintainers.
|
|
6282.6.11
by Jelmer Vernooij
Adjust some call counts. |
260 |
self.assertLength(6, self.hpss_calls) |
6366.1.4
by Jelmer Vernooij
Test connection count calls for most blackbox commands. |
261 |
self.assertLength(1, self.hpss_connections) |
6282.6.42
by Jelmer Vernooij
merge hpss-get-checkout-format. |
262 |
self.assertThat(self.hpss_calls, ContainsNoVfsCalls) |