/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1836.1.17 by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up.
1
# Copyright (C) 2006 by Canonical Ltd
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
21
from bzrlib import ignores
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
39
    def ls_equals(self, value, *args):
40
        out, err = self.run_bzr('ls', *args)
41
        self.assertEqual('', err)
42
        self.assertEqual(value, out)
43
44
    def test_ls_null_verbose(self):
45
        # Can't supply both
46
        self.run_bzr_error(['Cannot set both --verbose and --null'],
47
                           'ls', '--verbose', '--null')
48
49
    def test_ls_basic(self):
50
        """Test the abilities of 'bzr ls'"""
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
51
        self.ls_equals('.bzrignore\na\n')
52
        self.ls_equals('?        .bzrignore\n'
1836.1.17 by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up.
53
                       '?        a\n',
54
                       '--verbose')
55
        self.ls_equals('.bzrignore\n'
56
                       'a\n',
57
                       '--unknown')
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
58
        self.ls_equals('', '--ignored')
1836.1.17 by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up.
59
        self.ls_equals('', '--versioned')
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
60
        self.ls_equals('.bzrignore\n'
1836.1.17 by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up.
61
                       'a\n',
62
                       '--unknown', '--ignored', '--versioned')
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
63
        self.ls_equals('', '--ignored', '--versioned')
64
        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.
65
66
    def test_ls_added(self):
67
        self.wt.add(['a'])
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
                       'V        a\n',
70
                       '--verbose')
71
        self.wt.commit('add')
72
        
73
        self.build_tree(['subdir/'])
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
74
        self.ls_equals('?        .bzrignore\n'
1836.1.17 by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up.
75
                       'V        a\n'
76
                       '?        subdir/\n'
77
                       , '--verbose')
78
        self.build_tree(['subdir/b'])
79
        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
80
        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.
81
                       'V        a\n'
82
                       'V        subdir/\n'
83
                       'V        subdir/b\n'
84
                       , '--verbose')
85
86
    def test_ls_recursive(self):
87
        self.build_tree(['subdir/', 'subdir/b'])
88
        self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
89
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
90
        self.ls_equals('.bzrignore\n'
1836.1.17 by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up.
91
                       'a\n'
92
                       'subdir\n'
93
                       , '--non-recursive')
94
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
95
        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.
96
                       'V        a\n'
97
                       'V        subdir/\n'
98
                       , '--verbose', '--non-recursive')
99
100
        # Check what happens in a sub-directory
101
        os.chdir('subdir')
102
        self.ls_equals('b\n')
103
        self.ls_equals('b\0'
104
                  , '--null')
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
105
        self.ls_equals('.bzrignore\n'
1836.1.17 by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up.
106
                       'a\n'
107
                       'subdir\n'
108
                       'subdir/b\n'
109
                       , '--from-root')
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
110
        self.ls_equals('.bzrignore\0'
1836.1.17 by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up.
111
                       'a\0'
112
                       'subdir\0'
113
                       'subdir/b\0'
114
                       , '--from-root', '--null')
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
                       , '--from-root', '--non-recursive')
119
120
    def test_ls_revision(self):
121
        self.wt.add(['a'])
122
        self.wt.commit('add')
123
124
        self.build_tree(['subdir/'])
125
126
        # Check what happens when we supply a specific revision
127
        self.ls_equals('a\n', '--revision', '1')
128
        self.ls_equals('V        a\n'
129
                       , '--verbose', '--revision', '1')
130
131
        os.chdir('subdir')
132
        self.ls_equals('', '--revision', '1')
133
134
    def test_ls_ignored(self):
135
        # Now try to do ignored files.
136
        self.wt.add(['a', '.bzrignore'])
137
138
        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
139
        self.ls_equals('.bzrignore\n'
1836.1.17 by John Arbash Meinel
move 'bzr ls' tests into their own file, and fix them up.
140
                       'a\n'
141
                       'blah.py\n'
142
                       'blah.pyo\n'
143
                       'user-ignore\n'
144
                       )
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
145
        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.
146
                       'V        a\n'
147
                       '?        blah.py\n'
148
                       'I        blah.pyo\n'
149
                       'I        user-ignore\n'
150
                       , '--verbose')
1987.1.1 by John Arbash Meinel
Update the test suite to put HOME in a different directory
151
        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.
152
                       'user-ignore\n'
153
                       , '--ignored')
154
        self.ls_equals('blah.py\n'
155
                       , '--unknown')
156
        self.ls_equals('.bzrignore\n'
157
                       'a\n'
158
                       , '--versioned')
159