~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: 2010-02-10 15:46:03 UTC
  • mfrom: (4985.3.21 update)
  • mto: This revision was merged to the branch mainline in revision 5021.
  • Revision ID: v.ladeuil+lp@free.fr-20100210154603-k4no1gvfuqpzrw7p
Update performs two merges in a more logical order but stop on conflicts

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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):
 
39
    def ls_equals(self, value, args=None, recursive=True):
40
40
        command = 'ls'
41
41
        if args is not None:
42
42
            command += ' ' + args
 
43
        if recursive:
 
44
            command += ' -R'
43
45
        out, err = self.run_bzr(command)
44
46
        self.assertEqual('', err)
45
47
        self.assertEqualDiff(value, out)
52
54
    def test_ls_basic(self):
53
55
        """Test the abilities of 'bzr ls'"""
54
56
        self.ls_equals('.bzrignore\na\n')
 
57
        self.ls_equals('.bzrignore\na\n', './')
55
58
        self.ls_equals('?        .bzrignore\n'
56
59
                       '?        a\n',
57
60
                       '--verbose')
77
80
                       'V        a\n',
78
81
                       '--verbose')
79
82
        self.wt.commit('add')
80
 
        
 
83
 
81
84
        self.build_tree(['subdir/'])
82
85
        self.ls_equals('?        .bzrignore\n'
83
86
                       'V        a\n'
97
100
        self.ls_equals(
98
101
            '.bzrignore                                         \n'
99
102
            'a                                                  a-id\n'
100
 
            'subdir/                                            subdir-id\n', 
 
103
            'subdir/                                            subdir-id\n',
101
104
            '--show-ids')
102
105
        self.ls_equals(
103
106
            '?        .bzrignore\n'
104
107
            'V        a                                         a-id\n'
105
 
            'V        subdir/                                   subdir-id\n', 
 
108
            'V        subdir/                                   subdir-id\n',
106
109
            '--show-ids --verbose')
107
110
        self.ls_equals('.bzrignore\0\0'
108
111
                       'a\0a-id\0'
109
112
                       'subdir\0subdir-id\0', '--show-ids --null')
110
113
 
111
 
    def test_ls_recursive(self):
 
114
    def test_ls_no_recursive(self):
112
115
        self.build_tree(['subdir/', 'subdir/b'])
113
116
        self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
114
117
 
115
118
        self.ls_equals('.bzrignore\n'
116
119
                       'a\n'
117
120
                       'subdir/\n'
118
 
                       , '--non-recursive')
 
121
                       , recursive=False)
119
122
 
120
123
        self.ls_equals('V        .bzrignore\n'
121
124
                       'V        a\n'
122
125
                       'V        subdir/\n'
123
 
                       , '--verbose --non-recursive')
 
126
                       , '--verbose', recursive=False)
124
127
 
125
128
        # Check what happens in a sub-directory
126
129
        os.chdir('subdir')
127
130
        self.ls_equals('b\n')
128
131
        self.ls_equals('b\0'
129
132
                  , '--null')
130
 
        self.ls_equals('.bzrignore\n'
131
 
                       'a\n'
132
 
                       'subdir/\n'
133
 
                       'subdir/b\n'
 
133
        self.ls_equals('subdir/b\n'
134
134
                       , '--from-root')
135
 
        self.ls_equals('.bzrignore\0'
136
 
                       'a\0'
137
 
                       'subdir\0'
138
 
                       'subdir/b\0'
 
135
        self.ls_equals('subdir/b\0'
139
136
                       , '--from-root --null')
140
 
        self.ls_equals('.bzrignore\n'
141
 
                       'a\n'
142
 
                       'subdir/\n'
143
 
                       , '--from-root --non-recursive')
 
137
        self.ls_equals('subdir/b\n'
 
138
                       , '--from-root', recursive=False)
144
139
 
145
140
    def test_ls_path(self):
146
141
        """If a path is specified, files are listed with that prefix"""
164
159
                       'V        ../subdir/\n'
165
160
                       'V        ../subdir/b\n' ,
166
161
                       '.. --verbose')
167
 
        self.run_bzr_error('cannot specify both --from-root and PATH',
 
162
        self.run_bzr_error(['cannot specify both --from-root and PATH'],
168
163
                           'ls --from-root ..')
169
164
 
170
165
    def test_ls_revision(self):
226
221
 
227
222
    def test_kinds(self):
228
223
        self.build_tree(['subdir/'])
229
 
        self.ls_equals('.bzrignore\n' 
230
 
                       'a\n', 
 
224
        self.ls_equals('.bzrignore\n'
 
225
                       'a\n',
231
226
                       '--kind=file')
232
227
        self.ls_equals('subdir/\n',
233
228
                       '--kind=directory')
234
229
        self.ls_equals('',
235
230
                       '--kind=symlink')
236
 
        self.run_bzr_error('invalid kind specified', 'ls --kind=pile')
 
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)