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([ |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
36 |
('.bzrignore', b'*.pyo\n'), |
37 |
('a', b'hello\n'), |
|
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
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) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
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
|
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
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'""" |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
57 |
self.ls_equals('.bzrignore\na\n') |
58 |
self.ls_equals('.bzrignore\na\n', './') |
|
59 |
self.ls_equals('? .bzrignore\n' |
|
60 |
'? a\n', |
|
61 |
'--verbose') |
|
62 |
self.ls_equals('.bzrignore\n' |
|
63 |
'a\n', |
|
64 |
'--unknown') |
|
65 |
self.ls_equals('', '--ignored') |
|
66 |
self.ls_equals('', '--versioned') |
|
67 |
self.ls_equals('', '-V') |
|
68 |
self.ls_equals('.bzrignore\n' |
|
69 |
'a\n', |
|
70 |
'--unknown --ignored --versioned') |
|
71 |
self.ls_equals('.bzrignore\n' |
|
72 |
'a\n', |
|
73 |
'--unknown --ignored -V') |
|
74 |
self.ls_equals('', '--ignored --versioned') |
|
75 |
self.ls_equals('', '--ignored -V') |
|
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']) |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
80 |
self.ls_equals('? .bzrignore\n' |
81 |
'V a\n', |
|
82 |
'--verbose') |
|
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
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/']) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
86 |
self.ls_equals('? .bzrignore\n' |
87 |
'V a\n' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
88 |
'? subdir/\n', '--verbose') |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
89 |
self.build_tree(['subdir/b']) |
90 |
self.wt.add(['subdir/', 'subdir/b', '.bzrignore']) |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
91 |
self.ls_equals('V .bzrignore\n' |
92 |
'V a\n' |
|
93 |
'V subdir/\n' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
94 |
'V subdir/b\n', '--verbose') |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
95 |
|
|
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
96 |
def test_show_ids(self): |
97 |
self.build_tree(['subdir/']) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
98 |
self.wt.add(['a', 'subdir'], [b'a-id', b'subdir-id']) |
|
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
99 |
self.ls_equals( |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
100 |
'.bzrignore \n' |
101 |
'a a-id\n' |
|
102 |
'subdir/ subdir-id\n', |
|
103 |
'--show-ids') |
|
|
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
104 |
self.ls_equals( |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
105 |
'? .bzrignore\n' |
106 |
'V a a-id\n' |
|
107 |
'V subdir/ subdir-id\n', |
|
108 |
'--show-ids --verbose') |
|
109 |
self.ls_equals('.bzrignore\0\0' |
|
110 |
'a\0a-id\0' |
|
111 |
'subdir\0subdir-id\0', '--show-ids --null') |
|
|
1551.9.27
by Aaron Bentley
Implement show-ids for all output formats |
112 |
|
|
4206.2.1
by Ian Clatworthy
ls should be non-recursive by default |
113 |
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. |
114 |
self.build_tree(['subdir/', 'subdir/b']) |
115 |
self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore']) |
|
116 |
||
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
117 |
self.ls_equals('.bzrignore\n' |
118 |
'a\n' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
119 |
'subdir/\n', recursive=False) |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
120 |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
121 |
self.ls_equals('V .bzrignore\n' |
122 |
'V a\n' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
123 |
'V subdir/\n', '--verbose', recursive=False) |
|
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
|
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
126 |
self.ls_equals('b\n', working_dir='subdir') |
127 |
self.ls_equals('b\0', '--null', working_dir='subdir') |
|
128 |
self.ls_equals('subdir/b\n', '--from-root', working_dir='subdir') |
|
129 |
self.ls_equals('subdir/b\0', '--from-root --null', |
|
|
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 |
working_dir='subdir') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
131 |
self.ls_equals('subdir/b\n', '--from-root', recursive=False, |
|
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. |
132 |
working_dir='subdir') |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
133 |
|
|
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
134 |
def test_ls_path(self): |
135 |
"""If a path is specified, files are listed with that prefix""" |
|
136 |
self.build_tree(['subdir/', 'subdir/b']) |
|
137 |
self.wt.add(['subdir', 'subdir/b']) |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
138 |
self.ls_equals('subdir/b\n', |
139 |
'subdir') |
|
140 |
self.ls_equals('../.bzrignore\n' |
|
141 |
'../a\n' |
|
142 |
'../subdir/\n' |
|
143 |
'../subdir/b\n', |
|
144 |
'..', working_dir='subdir') |
|
145 |
self.ls_equals('../.bzrignore\0' |
|
146 |
'../a\0' |
|
147 |
'../subdir\0' |
|
148 |
'../subdir/b\0', |
|
149 |
'.. --null', working_dir='subdir') |
|
150 |
self.ls_equals('? ../.bzrignore\n' |
|
151 |
'? ../a\n' |
|
152 |
'V ../subdir/\n' |
|
153 |
'V ../subdir/b\n', |
|
154 |
'.. --verbose', working_dir='subdir') |
|
155 |
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. |
156 |
'ls --from-root ..', working_dir='subdir') |
|
2215.3.1
by Aaron Bentley
Allow ls to take a PATH |
157 |
|
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
158 |
def test_ls_revision(self): |
159 |
self.wt.add(['a']) |
|
160 |
self.wt.commit('add') |
|
161 |
||
162 |
self.build_tree(['subdir/']) |
|
163 |
||
164 |
# Check what happens when we supply a specific revision
|
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
165 |
self.ls_equals('a\n', '--revision 1') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
166 |
self.ls_equals('V a\n', '--verbose --revision 1') |
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
167 |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
168 |
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. |
169 |
|
|
2215.3.3
by Aaron Bentley
Get ls working on branches |
170 |
def test_ls_branch(self): |
171 |
"""If a branch is specified, files are listed from it""" |
|
172 |
self.build_tree(['subdir/', 'subdir/b']) |
|
173 |
self.wt.add(['subdir', 'subdir/b']) |
|
174 |
self.wt.commit('committing') |
|
175 |
branch = self.make_branch('branchdir') |
|
176 |
branch.pull(self.wt.branch) |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
177 |
self.ls_equals('branchdir/subdir/\n' |
178 |
'branchdir/subdir/b\n', |
|
179 |
'branchdir') |
|
180 |
self.ls_equals('branchdir/subdir/\n' |
|
181 |
'branchdir/subdir/b\n', |
|
182 |
'branchdir --revision 1') |
|
|
2215.3.3
by Aaron Bentley
Get ls working on branches |
183 |
|
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
184 |
def test_ls_ignored(self): |
185 |
# Now try to do ignored files.
|
|
186 |
self.wt.add(['a', '.bzrignore']) |
|
187 |
||
188 |
self.build_tree(['blah.py', 'blah.pyo', 'user-ignore']) |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
189 |
self.ls_equals('.bzrignore\n' |
190 |
'a\n' |
|
191 |
'blah.py\n' |
|
192 |
'blah.pyo\n' |
|
193 |
'user-ignore\n' |
|
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
194 |
)
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
195 |
self.ls_equals('V .bzrignore\n' |
196 |
'V a\n' |
|
197 |
'? blah.py\n' |
|
198 |
'I blah.pyo\n' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
199 |
'I user-ignore\n', '--verbose') |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
200 |
self.ls_equals('blah.pyo\n' |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
201 |
'user-ignore\n', '--ignored') |
202 |
self.ls_equals('blah.py\n', '--unknown') |
|
203 |
self.ls_equals('.bzrignore\n' |
|
204 |
'a\n', '--versioned') |
|
205 |
self.ls_equals('.bzrignore\n' |
|
206 |
'a\n', '-V') |
|
|
1836.1.17
by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up. |
207 |
|
|
1551.9.24
by Aaron Bentley
Unhide ls, add kind flag |
208 |
def test_kinds(self): |
209 |
self.build_tree(['subdir/']) |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
210 |
self.ls_equals('.bzrignore\n' |
211 |
'a\n', |
|
212 |
'--kind=file') |
|
213 |
self.ls_equals('subdir/\n', |
|
214 |
'--kind=directory') |
|
215 |
self.ls_equals('', |
|
216 |
'--kind=symlink') |
|
217 |
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. |
218 |
|
219 |
def test_ls_path_nonrecursive(self): |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
220 |
self.ls_equals('%s/.bzrignore\n' |
221 |
'%s/a\n' |
|
|
4272.1.2
by Jelmer Vernooij
Fix formatting per Johns comments. |
222 |
% (self.test_dir, self.test_dir), |
|
4272.1.1
by Jelmer Vernooij
non-recursive bzr ls now works properly when a path is specified. |
223 |
self.test_dir, recursive=False) |
|
5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
224 |
|
225 |
def test_ls_directory(self): |
|
226 |
"""Test --directory option""" |
|
227 |
self.wt = self.make_branch_and_tree('dir') |
|
228 |
self.build_tree(['dir/sub/', 'dir/sub/file']) |
|
229 |
self.wt.add(['sub', 'sub/file']) |
|
230 |
self.wt.commit('commit') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
231 |
self.ls_equals('sub/\nsub/file\n', '--directory=dir') |
232 |
self.ls_equals('sub/file\n', '-d dir sub') |
|
|
6283.1.5
by Jelmer Vernooij
Add hpss call count test for 'bzr ls'. |
233 |
|
234 |
||
|
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. |
235 |
class TestSmartServerLs(tests.TestCaseWithTransport): |
|
6283.1.5
by Jelmer Vernooij
Add hpss call count test for 'bzr ls'. |
236 |
|
237 |
def test_simple_ls(self): |
|
238 |
self.setup_smart_server_with_call_log() |
|
239 |
t = self.make_branch_and_tree('branch') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
240 |
self.build_tree_contents([('branch/foo', b'thecontents')]) |
|
6283.1.5
by Jelmer Vernooij
Add hpss call count test for 'bzr ls'. |
241 |
t.add("foo") |
242 |
t.commit("message") |
|
243 |
self.reset_smart_call_log() |
|
244 |
out, err = self.run_bzr(['ls', self.get_url('branch')]) |
|
245 |
# This figure represent the amount of work to perform this use case. It
|
|
246 |
# is entirely ok to reduce this number if a test fails due to rpc_count
|
|
247 |
# being too low. If rpc_count increases, more network roundtrips have
|
|
248 |
# become necessary for this use case. Please do not adjust this number
|
|
249 |
# upwards without agreement from bzr's network support maintainers.
|
|
|
6282.6.11
by Jelmer Vernooij
Adjust some call counts. |
250 |
self.assertLength(6, self.hpss_calls) |
|
6366.1.4
by Jelmer Vernooij
Test connection count calls for most blackbox commands. |
251 |
self.assertLength(1, self.hpss_connections) |
|
6282.6.42
by Jelmer Vernooij
merge hpss-get-checkout-format. |
252 |
self.assertThat(self.hpss_calls, ContainsNoVfsCalls) |