~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2011-12-16 16:38:33 UTC
  • mto: This revision was merged to the branch mainline in revision 6387.
  • Revision ID: v.ladeuil+lp@free.fr-20111216163833-4igwmwi1dmxbbebw
Migrate add.maximum_file_size to the new config scheme

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
16
16
 
17
17
"""External tests of 'bzr ls'"""
18
18
 
19
 
from bzrlib import (
20
 
    ignores,
21
 
    tests,
22
 
    )
 
19
import os
 
20
 
 
21
from bzrlib import ignores
 
22
from bzrlib.tests import TestCaseWithTransport
23
23
from bzrlib.tests.matchers import ContainsNoVfsCalls
24
24
 
25
25
 
26
 
class TestLS(tests.TestCaseWithTransport):
 
26
class TestLS(TestCaseWithTransport):
27
27
 
28
28
    def setUp(self):
29
29
        super(TestLS, self).setUp()
37
37
                                 ('a', 'hello\n'),
38
38
                                 ])
39
39
 
40
 
    def ls_equals(self, value, args=None, recursive=True, working_dir=None):
 
40
    def ls_equals(self, value, args=None, recursive=True):
41
41
        command = 'ls'
42
42
        if args is not None:
43
43
            command += ' ' + args
44
44
        if recursive:
45
45
            command += ' -R'
46
 
        out, err = self.run_bzr(command, working_dir=working_dir)
 
46
        out, err = self.run_bzr(command)
47
47
        self.assertEqual('', err)
48
48
        self.assertEqualDiff(value, out)
49
49
 
127
127
                       , '--verbose', recursive=False)
128
128
 
129
129
        # Check what happens in a sub-directory
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')
 
130
        os.chdir('subdir')
 
131
        self.ls_equals('b\n')
 
132
        self.ls_equals('b\0'
 
133
                  , '--null')
 
134
        self.ls_equals('subdir/b\n'
 
135
                       , '--from-root')
 
136
        self.ls_equals('subdir/b\0'
 
137
                       , '--from-root --null')
 
138
        self.ls_equals('subdir/b\n'
 
139
                       , '--from-root', recursive=False)
137
140
 
138
141
    def test_ls_path(self):
139
142
        """If a path is specified, files are listed with that prefix"""
141
144
        self.wt.add(['subdir', 'subdir/b'])
142
145
        self.ls_equals('subdir/b\n' ,
143
146
                       'subdir')
 
147
        os.chdir('subdir')
144
148
        self.ls_equals('../.bzrignore\n'
145
149
                       '../a\n'
146
150
                       '../subdir/\n'
147
151
                       '../subdir/b\n' ,
148
 
                       '..', working_dir='subdir')
 
152
                       '..')
149
153
        self.ls_equals('../.bzrignore\0'
150
154
                       '../a\0'
151
155
                       '../subdir\0'
152
156
                       '../subdir/b\0' ,
153
 
                       '.. --null', working_dir='subdir')
 
157
                       '.. --null')
154
158
        self.ls_equals('?        ../.bzrignore\n'
155
159
                       '?        ../a\n'
156
160
                       'V        ../subdir/\n'
157
161
                       'V        ../subdir/b\n' ,
158
 
                       '.. --verbose', working_dir='subdir')
 
162
                       '.. --verbose')
159
163
        self.run_bzr_error(['cannot specify both --from-root and PATH'],
160
 
                           'ls --from-root ..', working_dir='subdir')
 
164
                           'ls --from-root ..')
161
165
 
162
166
    def test_ls_revision(self):
163
167
        self.wt.add(['a'])
170
174
        self.ls_equals('V        a\n'
171
175
                       , '--verbose --revision 1')
172
176
 
173
 
        self.ls_equals('', '--revision 1', working_dir='subdir')
 
177
        os.chdir('subdir')
 
178
        self.ls_equals('', '--revision 1')
174
179
 
175
180
    def test_ls_branch(self):
176
181
        """If a branch is specified, files are listed from it"""
242
247
        self.ls_equals('sub/file\n', '-d dir sub')
243
248
 
244
249
 
245
 
class TestSmartServerLs(tests.TestCaseWithTransport):
 
250
class TestSmartServerLs(TestCaseWithTransport):
246
251
 
247
252
    def test_simple_ls(self):
248
253
        self.setup_smart_server_with_call_log()
258
263
        # become necessary for this use case. Please do not adjust this number
259
264
        # upwards without agreement from bzr's network support maintainers.
260
265
        self.assertLength(6, self.hpss_calls)
261
 
        self.assertLength(1, self.hpss_connections)
262
266
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)