/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2830.3.1 by Martin Pool
Make run_bzr_decode undeprecated again, but put it in the particular test class
1
# Copyright (C) 2006, 2007 Canonical Ltd
1685.1.76 by Wouter van Heyst
codecleanup
2
#
1185.85.10 by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message
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.
1685.1.76 by Wouter van Heyst
codecleanup
7
#
1185.85.10 by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message
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.
1685.1.76 by Wouter van Heyst
codecleanup
12
#
1185.85.10 by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message
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
1185.85.10 by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message
16
1685.1.76 by Wouter van Heyst
codecleanup
17
"""Black-box tests for bzr handling non-ascii characters."""
1185.85.10 by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message
18
19
import os
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
20
import sys
1685.1.76 by Wouter van Heyst
codecleanup
21
4498.4.1 by Vincent Ladeuil
Various cleanups.
22
from bzrlib import (
23
    osutils,
24
    tests,
25
    urlutils,
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
26
    )
4498.4.1 by Vincent Ladeuil
Various cleanups.
27
from bzrlib.tests import EncodingAdapter
1185.85.10 by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message
28
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
29
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
30
def load_tests(standard_tests, module, loader):
4498.4.1 by Vincent Ladeuil
Various cleanups.
31
    return tests.multiply_tests(standard_tests,
32
                                EncodingAdapter.encoding_scenarios,
33
                                loader.suiteClass())
34
35
36
class TestNonAscii(tests.TestCaseWithTransport):
1185.85.67 by John Arbash Meinel
Starting work on a test adapter for multiple encodings.
37
    """Test that bzr handles files/committers/etc which are non-ascii."""
38
1185.85.10 by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message
39
    def setUp(self):
40
        super(TestNonAscii, self).setUp()
3224.5.4 by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding.
41
        self._orig_encoding = osutils._cached_user_encoding
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
42
3224.5.4 by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding.
43
        osutils._cached_user_encoding = self.encoding
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
44
        email = self.info['committer'] + ' <joe@foo.com>'
3224.5.4 by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding.
45
        os.environ['BZR_EMAIL'] = email.encode(osutils.get_user_encoding())
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
46
        self.create_base()
47
48
    def tearDown(self):
3224.5.4 by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding.
49
        osutils._cached_user_encoding = self._orig_encoding
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
50
        super(TestNonAscii, self).tearDown()
1185.85.10 by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message
51
2823.2.4 by Daniel Watkins
Added 'working_dir' to 'run_bzr_decode'.
52
    def run_bzr_decode(self, args, encoding=None, fail=False, retcode=None,
4498.4.1 by Vincent Ladeuil
Various cleanups.
53
                       working_dir=None):
2830.3.1 by Martin Pool
Make run_bzr_decode undeprecated again, but put it in the particular test class
54
        """Run bzr and decode the output into a particular encoding.
55
56
        Returns a string containing the stdout output from bzr.
57
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
58
        :param fail: If true, the operation is expected to fail with
2830.3.1 by Martin Pool
Make run_bzr_decode undeprecated again, but put it in the particular test class
59
            a UnicodeError.
60
        """
61
        if encoding is None:
3224.5.4 by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding.
62
            encoding = osutils.get_user_encoding()
2830.3.1 by Martin Pool
Make run_bzr_decode undeprecated again, but put it in the particular test class
63
        try:
4498.4.1 by Vincent Ladeuil
Various cleanups.
64
            out = self.run_bzr(args,
65
                               output_encoding=encoding, encoding=encoding,
66
                               retcode=retcode, working_dir=working_dir)[0]
2830.3.1 by Martin Pool
Make run_bzr_decode undeprecated again, but put it in the particular test class
67
            return out.decode(encoding)
68
        except UnicodeError, e:
69
            if not fail:
70
                raise
71
        else:
72
            # This command, run from the regular command line, will give a
73
            # traceback to the user.  That's not really good for a situation
74
            # that can be provoked just by the interaction of their input data
75
            # and locale, as some of these are.  What would be better?
76
            if fail:
77
                self.fail("Expected UnicodeError not raised")
78
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
79
    def _check_OSX_can_roundtrip(self, path, fs_enc=None):
80
        """Stop the test if it's about to fail or errors out.
81
82
        Until we get proper support on OSX for accented paths (in fact, any
83
        path whose NFD decomposition is different than the NFC one), this is
84
        the best way to keep test active (as opposed to disabling them
85
        completely). This is a stop gap. The tests should at least be rewritten
4498.4.5 by Vincent Ladeuil
Fix comment.
86
        so that the failing ones are clearly separated from the passing ones.
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
87
        """
88
        if fs_enc is None:
89
            fs_enc = osutils._fs_enc
90
        if sys.platform == 'darwin':
91
            encoded = path.encode(fs_enc)
92
            import unicodedata
93
            normal_thing = unicodedata.normalize('NFD', path)
94
            mac_encoded = normal_thing.encode(fs_enc)
95
            if mac_encoded != encoded:
4498.4.4 by Vincent Ladeuil
Use KnownFailure so that XFAIL tests are displayed.
96
                raise tests.KnownFailure(
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
97
                    'Unable to roundtrip path %r on OSX filesystem'
98
                    ' using encoding "%s"'
99
                    % (path, fs_enc))
100
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
101
    def create_base(self):
4498.4.1 by Vincent Ladeuil
Various cleanups.
102
        fs_enc = osutils._fs_enc
1711.4.11 by John Arbash Meinel
Skip non_ascii tests that won't write properly to the screen
103
        terminal_enc = osutils.get_terminal_encoding()
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
104
        fname = self.info['filename']
1685.1.57 by Martin Pool
[broken] Skip unicode blackbox tests if not supported by filesystem
105
        dir_name = self.info['directory']
106
        for thing in [fname, dir_name]:
107
            try:
108
                thing.encode(fs_enc)
109
            except UnicodeEncodeError:
4498.4.1 by Vincent Ladeuil
Various cleanups.
110
                raise tests.TestSkipped(
111
                    'Unable to represent path %r in filesystem encoding "%s"'
112
                    % (thing, fs_enc))
1711.4.11 by John Arbash Meinel
Skip non_ascii tests that won't write properly to the screen
113
            try:
114
                thing.encode(terminal_enc)
115
            except UnicodeEncodeError:
4498.4.1 by Vincent Ladeuil
Various cleanups.
116
                raise tests.TestSkipped(
117
                    'Unable to represent path %r in terminal encoding "%s"'
118
                    ' (even though it is valid in filesystem encoding "%s")'
119
                    % (thing, terminal_enc, fs_enc))
1685.1.74 by Wouter van Heyst
fix nonascii tests to run properly under LANG=C
120
1836.2.1 by John Arbash Meinel
Switch setup to use internals rather than run_bzr
121
        wt = self.make_branch_and_tree('.')
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
122
        self.build_tree_contents([('a', 'foo\n')])
1836.2.1 by John Arbash Meinel
Switch setup to use internals rather than run_bzr
123
        wt.add('a')
124
        wt.commit('adding a')
1685.1.74 by Wouter van Heyst
fix nonascii tests to run properly under LANG=C
125
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
126
        self.build_tree_contents(
127
            [('b', 'non-ascii \xFF\xFF\xFC\xFB\x00 in b\n')])
1836.2.1 by John Arbash Meinel
Switch setup to use internals rather than run_bzr
128
        wt.add('b')
129
        wt.commit(self.info['message'])
1685.1.74 by Wouter van Heyst
fix nonascii tests to run properly under LANG=C
130
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
131
        self.build_tree_contents([(fname, 'unicode filename\n')])
1836.2.1 by John Arbash Meinel
Switch setup to use internals rather than run_bzr
132
        wt.add(fname)
133
        wt.commit(u'And a unicode file\n')
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
134
        self.wt = wt
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
135
        # FIXME: We don't check that the add went well, in fact, it doesn't on
136
        # OSX (when LC_ALL is set correctly) because the added path doesn't
137
        # match the one used on OSX. But checking here will require more
138
        # invasive changes than adding the _check_OSX_can_roundtrip(), so I
139
        # punt for now -- vila 20090702
1185.85.66 by John Arbash Meinel
Adding test for swedish
140
1185.85.15 by John Arbash Meinel
Updated bzr status, adding test_cat
141
    def test_status(self):
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
142
        self.build_tree_contents(
143
            [(self.info['filename'], 'changed something\n')])
144
        txt = self.run_bzr_decode('status')
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
145
        self._check_OSX_can_roundtrip(self.info['filename'])
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
146
        self.assertEqual(u'modified:\n  %s\n' % (self.info['filename'],), txt)
1185.85.15 by John Arbash Meinel
Updated bzr status, adding test_cat
147
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
148
        txt = self.run_bzr_decode('status', encoding='ascii')
1685.1.76 by Wouter van Heyst
codecleanup
149
        expected = u'modified:\n  %s\n' % (
150
                    self.info['filename'].encode('ascii', 'replace'),)
151
        self.assertEqual(expected, txt)
152
1185.85.15 by John Arbash Meinel
Updated bzr status, adding test_cat
153
    def test_cat(self):
154
        # bzr cat shouldn't change the contents
155
        # using run_bzr since that doesn't decode
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
156
        txt = self.run_bzr('cat b')[0]
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
157
        self.assertEqual('non-ascii \xFF\xFF\xFC\xFB\x00 in b\n', txt)
1185.85.15 by John Arbash Meinel
Updated bzr status, adding test_cat
158
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
159
        self._check_OSX_can_roundtrip(self.info['filename'])
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
160
        txt = self.run_bzr(['cat', self.info['filename']])[0]
1185.85.41 by John Arbash Meinel
Changing test_non_ascii.py so that it will keep trying even if it can't encode one piece.
161
        self.assertEqual('unicode filename\n', txt)
1185.85.17 by John Arbash Meinel
switching to using the default encoding instead of utf-8
162
163
    def test_cat_revision(self):
1185.85.72 by John Arbash Meinel
Fix some of the tests.
164
        committer = self.info['committer']
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
165
        txt = self.run_bzr_decode('cat-revision -r 1')
1185.85.72 by John Arbash Meinel
Fix some of the tests.
166
        self.failUnless(committer in txt,
167
                        'failed to find %r in %r' % (committer, txt))
1185.85.17 by John Arbash Meinel
switching to using the default encoding instead of utf-8
168
1185.85.72 by John Arbash Meinel
Fix some of the tests.
169
        msg = self.info['message']
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
170
        txt = self.run_bzr_decode('cat-revision -r 2')
1185.85.72 by John Arbash Meinel
Fix some of the tests.
171
        self.failUnless(msg in txt, 'failed to find %r in %r' % (msg, txt))
1185.85.18 by John Arbash Meinel
Updated mkdir, added to test_log
172
173
    def test_mkdir(self):
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
174
        txt = self.run_bzr_decode(['mkdir', self.info['directory']])
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
175
        self.assertEqual(u'added %s\n' % self.info['directory'], txt)
176
177
        # The text should be garbled, but the command should succeed
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
178
        txt = self.run_bzr_decode(['mkdir', self.info['directory'] + '2'],
179
                                  encoding='ascii')
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
180
        expected = u'added %s2\n' % (self.info['directory'],)
181
        expected = expected.encode('ascii', 'replace')
182
        self.assertEqual(expected, txt)
1185.85.19 by John Arbash Meinel
Updated bzr relpath
183
184
    def test_relpath(self):
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
185
        txt = self.run_bzr_decode(['relpath', self.info['filename']])
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
186
        self.assertEqual(self.info['filename'] + '\n', txt)
1185.85.19 by John Arbash Meinel
Updated bzr relpath
187
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
188
        self.run_bzr_decode(['relpath', self.info['filename']],
2823.2.2 by Daniel Watkins
Merged bzr.dev.
189
                            encoding='ascii', fail=True)
1185.85.22 by John Arbash Meinel
Updated cmd_inventory. Changing from having each Command request an encoded stdout to providing one before calling run()
190
191
    def test_inventory(self):
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
192
        txt = self.run_bzr_decode('inventory')
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
193
        self._check_OSX_can_roundtrip(self.info['filename'])
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
194
        self.assertEqual(['a', 'b', self.info['filename']],
1185.85.22 by John Arbash Meinel
Updated cmd_inventory. Changing from having each Command request an encoded stdout to providing one before calling run()
195
                         txt.splitlines())
196
1185.85.23 by John Arbash Meinel
Adding more inventory tests.
197
        # inventory should fail if unable to encode
2823.2.2 by Daniel Watkins
Merged bzr.dev.
198
        self.run_bzr_decode('inventory', encoding='ascii', fail=True)
1185.85.23 by John Arbash Meinel
Adding more inventory tests.
199
200
        # We don't really care about the ids themselves,
201
        # but the command shouldn't fail
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
202
        txt = self.run_bzr_decode('inventory --show-ids')
1185.85.24 by John Arbash Meinel
Moved run_bzr_decode into TestCase
203
204
    def test_revno(self):
205
        # There isn't a lot to test here, since revno should always
206
        # be an integer
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
207
        self.assertEqual('3\n', self.run_bzr_decode('revno'))
208
        self.assertEqual('3\n', self.run_bzr_decode('revno', encoding='ascii'))
1185.85.24 by John Arbash Meinel
Moved run_bzr_decode into TestCase
209
210
    def test_revision_info(self):
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
211
        self.run_bzr_decode('revision-info -r 1')
1185.85.24 by John Arbash Meinel
Moved run_bzr_decode into TestCase
212
1685.1.76 by Wouter van Heyst
codecleanup
213
        # TODO: jam 20060105 If we support revisions with non-ascii characters,
214
        # this should be strict and fail.
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
215
        self.run_bzr_decode('revision-info -r 1', encoding='ascii')
1185.85.25 by John Arbash Meinel
updated 'bzr mv'
216
217
    def test_mv(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
218
        fname1 = self.info['filename']
219
        fname2 = self.info['filename'] + '2'
220
        dirname = self.info['directory']
1185.85.26 by John Arbash Meinel
bzr mv should succeed even if it can't display the paths.
221
1685.1.76 by Wouter van Heyst
codecleanup
222
        # fname1 already exists
2823.2.2 by Daniel Watkins
Merged bzr.dev.
223
        self.run_bzr_decode(['mv', 'a', fname1], fail=True)
1185.85.26 by John Arbash Meinel
bzr mv should succeed even if it can't display the paths.
224
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
225
        txt = self.run_bzr_decode(['mv', 'a', fname2])
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
226
        self.assertEqual(u'a => %s\n' % fname2, txt)
1185.85.26 by John Arbash Meinel
bzr mv should succeed even if it can't display the paths.
227
        self.failIfExists('a')
228
        self.failUnlessExists(fname2)
1185.85.25 by John Arbash Meinel
updated 'bzr mv'
229
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
230
        # After 'mv' we need to re-open the working tree
231
        self.wt = self.wt.bzrdir.open_workingtree()
232
        self.wt.commit('renamed to non-ascii')
1185.85.25 by John Arbash Meinel
updated 'bzr mv'
233
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
234
        os.mkdir(dirname)
235
        self.wt.add(dirname)
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
236
        txt = self.run_bzr_decode(['mv', fname1, fname2, dirname])
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
237
        self._check_OSX_can_roundtrip(self.info['filename'])
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
238
        self.assertEqual([u'%s => %s/%s' % (fname1, dirname, fname1),
239
                          u'%s => %s/%s' % (fname2, dirname, fname2)]
1185.85.26 by John Arbash Meinel
bzr mv should succeed even if it can't display the paths.
240
                         , txt.splitlines())
241
242
        # The rename should still succeed
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
243
        newpath = u'%s/%s' % (dirname, fname2)
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
244
        txt = self.run_bzr_decode(['mv', newpath, 'a'], encoding='ascii')
1185.85.26 by John Arbash Meinel
bzr mv should succeed even if it can't display the paths.
245
        self.failUnlessExists('a')
1685.1.2 by John Arbash Meinel
Re-enabling the non_ascii tests after fixing trace.py, bzr ignore also does the right thing now
246
        self.assertEqual(newpath.encode('ascii', 'replace') + ' => a\n', txt)
1185.85.26 by John Arbash Meinel
bzr mv should succeed even if it can't display the paths.
247
1185.85.27 by John Arbash Meinel
Updated bzr branch and bzr pull
248
    def test_branch(self):
249
        # We should be able to branch into a directory that
250
        # has a unicode name, even if we can't display the name
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
251
        self.run_bzr_decode(['branch', u'.', self.info['directory']])
252
        self.run_bzr_decode(['branch', u'.', self.info['directory'] + '2'],
253
                            encoding='ascii')
1185.85.27 by John Arbash Meinel
Updated bzr branch and bzr pull
254
255
    def test_pull(self):
256
        # Make sure we can pull from paths that can't be encoded
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
257
        dirname1 = self.info['directory']
258
        dirname2 = self.info['directory'] + '2'
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
259
        url1 = urlutils.local_path_to_url(dirname1)
260
        url2 = urlutils.local_path_to_url(dirname2)
261
        out_bzrdir = self.wt.bzrdir.sprout(url1)
262
        out_bzrdir.sprout(url2)
1185.85.27 by John Arbash Meinel
Updated bzr branch and bzr pull
263
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
264
        self.build_tree_contents(
265
            [(osutils.pathjoin(dirname1, "a"), 'different text\n')])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
266
        self.wt.commit('mod a')
1185.85.27 by John Arbash Meinel
Updated bzr branch and bzr pull
267
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
268
        txt = self.run_bzr_decode('pull', working_dir=dirname2)
269
270
        expected = osutils.pathjoin(osutils.getcwd(), dirname1)
3596.3.1 by James Westby
Give the user a bit more information about which saved location is being used.
271
        self.assertEqual(u'Using saved parent location: %s/\n'
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
272
                'No revisions to pull.\n' % (expected,), txt)
1185.85.27 by John Arbash Meinel
Updated bzr branch and bzr pull
273
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
274
        self.build_tree_contents(
275
            [(osutils.pathjoin(dirname1, 'a'), 'and yet more\n')])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
276
        self.wt.commit(u'modifying a by ' + self.info['committer'])
1185.85.27 by John Arbash Meinel
Updated bzr branch and bzr pull
277
278
        # We should be able to pull, even if our encoding is bad
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
279
        self.run_bzr_decode('pull --verbose', encoding='ascii',
280
                            working_dir=dirname2)
1185.85.31 by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag.
281
282
    def test_push(self):
283
        # TODO: Test push to an SFTP location
284
        # Make sure we can pull from paths that can't be encoded
1685.1.24 by John Arbash Meinel
cmd_push should use URLs throughout.
285
        # TODO: jam 20060427 For drastically improving performance, we probably
286
        #       could create a local repository, so it wouldn't have to copy
287
        #       the files around as much.
288
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
289
        dirname = self.info['directory']
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
290
        self.run_bzr_decode(['push', dirname])
1185.85.31 by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag.
291
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
292
        self.build_tree_contents([('a', 'adding more text\n')])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
293
        self.wt.commit('added some stuff')
1185.85.31 by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag.
294
1685.1.76 by Wouter van Heyst
codecleanup
295
        # TODO: check the output text is properly encoded
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
296
        self.run_bzr_decode('push')
1185.85.31 by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag.
297
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
298
        self.build_tree_contents(
299
            [('a', 'and a bit more: \n%s\n' % (dirname.encode('utf-8'),))])
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
300
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
301
        self.wt.commit('Added some ' + dirname)
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
302
        self.run_bzr_decode('push --verbose', encoding='ascii')
303
304
        self.run_bzr_decode(['push', '--verbose', dirname + '2'])
305
306
        self.run_bzr_decode(['push', '--verbose', dirname + '3'],
307
                            encoding='ascii')
308
309
        self.run_bzr_decode(['push', '--verbose', '--create-prefix',
310
                            dirname + '4/' + dirname + '5'])
311
        self.run_bzr_decode(['push', '--verbose', '--create-prefix',
312
                            dirname + '6/' + dirname + '7'], encoding='ascii')
1685.1.24 by John Arbash Meinel
cmd_push should use URLs throughout.
313
1185.85.32 by John Arbash Meinel
Updated bzr renames
314
    def test_renames(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
315
        fname = self.info['filename'] + '2'
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
316
        self.wt.rename_one('a', fname)
317
        txt = self.run_bzr_decode('renames')
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
318
        self.assertEqual(u'a => %s\n' % fname, txt)
1185.85.32 by John Arbash Meinel
Updated bzr renames
319
2823.2.2 by Daniel Watkins
Merged bzr.dev.
320
        self.run_bzr_decode('renames', fail=True, encoding='ascii')
1185.85.32 by John Arbash Meinel
Updated bzr renames
321
1185.85.33 by John Arbash Meinel
Updated bzr remove, still remove --verbose still broken.
322
    def test_remove(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
323
        fname = self.info['filename']
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
324
        txt = self.run_bzr_decode(['remove', fname], encoding='ascii')
1185.85.33 by John Arbash Meinel
Updated bzr remove, still remove --verbose still broken.
325
326
    def test_remove_verbose(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
327
        fname = self.info['filename']
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
328
        txt = self.run_bzr_decode(['remove', '--verbose', fname],
329
                                  encoding='ascii')
1185.85.33 by John Arbash Meinel
Updated bzr remove, still remove --verbose still broken.
330
1185.85.34 by John Arbash Meinel
Updating 'bzr file-id' exposed that we weren't allowing unicode file ids. Enabling them reveals a lot more bugs.
331
    def test_file_id(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
332
        fname = self.info['filename']
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
333
        txt = self.run_bzr_decode(['file-id', fname])
1185.85.34 by John Arbash Meinel
Updating 'bzr file-id' exposed that we weren't allowing unicode file ids. Enabling them reveals a lot more bugs.
334
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
335
        # TODO: jam 20060106 We don't support non-ascii file ids yet,
1185.85.35 by John Arbash Meinel
Updated file-path
336
        #       so there is nothing which would fail in ascii encoding
337
        #       This *should* be retcode=3
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
338
        txt = self.run_bzr_decode(['file-id', fname], encoding='ascii')
1185.85.34 by John Arbash Meinel
Updating 'bzr file-id' exposed that we weren't allowing unicode file ids. Enabling them reveals a lot more bugs.
339
1185.85.35 by John Arbash Meinel
Updated file-path
340
    def test_file_path(self):
341
        # Create a directory structure
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
342
        fname = self.info['filename']
1185.85.72 by John Arbash Meinel
Fix some of the tests.
343
        dirname = self.info['directory']
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
344
        self.build_tree_contents([
345
            ('base/', ),
346
            (osutils.pathjoin('base', '%s/' % (dirname,)), )])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
347
        self.wt.add('base')
348
        self.wt.add('base/'+dirname)
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
349
        path = osutils.pathjoin('base', dirname, fname)
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
350
        self._check_OSX_can_roundtrip(self.info['filename'])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
351
        self.wt.rename_one(fname, path)
352
        self.wt.commit('moving things around')
1185.85.35 by John Arbash Meinel
Updated file-path
353
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
354
        txt = self.run_bzr_decode(['file-path', path])
1185.85.35 by John Arbash Meinel
Updated file-path
355
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
356
        # TODO: jam 20060106 We don't support non-ascii file ids yet,
1185.85.35 by John Arbash Meinel
Updated file-path
357
        #       so there is nothing which would fail in ascii encoding
358
        #       This *should* be retcode=3
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
359
        txt = self.run_bzr_decode(['file-path', path], encoding='ascii')
1185.85.34 by John Arbash Meinel
Updating 'bzr file-id' exposed that we weren't allowing unicode file ids. Enabling them reveals a lot more bugs.
360
1185.85.36 by John Arbash Meinel
Working on tests for revision-history, ancestry, and diff
361
    def test_revision_history(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
362
        # TODO: jam 20060106 We don't support non-ascii revision ids yet,
1185.85.36 by John Arbash Meinel
Working on tests for revision-history, ancestry, and diff
363
        #       so there is nothing which would fail in ascii encoding
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
364
        txt = self.run_bzr_decode('revision-history')
1185.85.36 by John Arbash Meinel
Working on tests for revision-history, ancestry, and diff
365
366
    def test_ancestry(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
367
        # TODO: jam 20060106 We don't support non-ascii revision ids yet,
1185.85.36 by John Arbash Meinel
Working on tests for revision-history, ancestry, and diff
368
        #       so there is nothing which would fail in ascii encoding
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
369
        txt = self.run_bzr_decode('ancestry')
1185.85.36 by John Arbash Meinel
Working on tests for revision-history, ancestry, and diff
370
371
    def test_diff(self):
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
372
        self._check_OSX_can_roundtrip(self.info['filename'])
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
373
        # TODO: jam 20060106 diff is a difficult one to test, because it
1185.85.36 by John Arbash Meinel
Working on tests for revision-history, ancestry, and diff
374
        #       shouldn't encode the file contents, but it needs some sort
375
        #       of encoding for the paths, etc which are displayed.
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
376
        self.build_tree_contents([(self.info['filename'], 'newline\n')])
1685.1.78 by Wouter van Heyst
more code cleanup
377
        txt = self.run_bzr('diff', retcode=1)[0]
1185.85.41 by John Arbash Meinel
Changing test_non_ascii.py so that it will keep trying even if it can't encode one piece.
378
1185.85.49 by John Arbash Meinel
Updated cmd_deleted, including adding --show-ids option.
379
    def test_deleted(self):
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
380
        self._check_OSX_can_roundtrip(self.info['filename'])
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
381
        fname = self.info['filename']
1185.85.49 by John Arbash Meinel
Updated cmd_deleted, including adding --show-ids option.
382
        os.remove(fname)
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
383
        self.wt.remove(fname)
1185.85.49 by John Arbash Meinel
Updated cmd_deleted, including adding --show-ids option.
384
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
385
        txt = self.run_bzr_decode('deleted')
1185.85.49 by John Arbash Meinel
Updated cmd_deleted, including adding --show-ids option.
386
        self.assertEqual(fname+'\n', txt)
387
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
388
        txt = self.run_bzr_decode('deleted --show-ids')
1185.85.49 by John Arbash Meinel
Updated cmd_deleted, including adding --show-ids option.
389
        self.failUnless(txt.startswith(fname))
390
1185.85.51 by John Arbash Meinel
Adding tests to make sure deleted and modified fail if cannot encode names.
391
        # Deleted should fail if cannot decode
392
        # Because it is giving the exact paths
393
        # which might be used by a front end
2823.2.2 by Daniel Watkins
Merged bzr.dev.
394
        self.run_bzr_decode('deleted', encoding='ascii', fail=True)
1185.85.51 by John Arbash Meinel
Adding tests to make sure deleted and modified fail if cannot encode names.
395
1185.85.50 by John Arbash Meinel
Updated cmd_modified
396
    def test_modified(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
397
        fname = self.info['filename']
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
398
        self.build_tree_contents([(fname, 'modified\n')])
1185.85.50 by John Arbash Meinel
Updated cmd_modified
399
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
400
        txt = self.run_bzr_decode('modified')
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
401
        self._check_OSX_can_roundtrip(self.info['filename'])
3251.6.3 by Adrian Wilkins
Simplified and fixed test code
402
        self.assertEqual('"'+fname+'"'+'\n', txt)
1185.85.50 by John Arbash Meinel
Updated cmd_modified
403
2823.2.2 by Daniel Watkins
Merged bzr.dev.
404
        self.run_bzr_decode('modified', encoding='ascii', fail=True)
1185.85.51 by John Arbash Meinel
Adding tests to make sure deleted and modified fail if cannot encode names.
405
1185.85.52 by John Arbash Meinel
Updated cmd_added, which obviously had no tests, because it had a bug in it.
406
    def test_added(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
407
        fname = self.info['filename'] + '2'
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
408
        self.build_tree_contents([(fname, 'added\n')])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
409
        self.wt.add(fname)
1185.85.52 by John Arbash Meinel
Updated cmd_added, which obviously had no tests, because it had a bug in it.
410
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
411
        txt = self.run_bzr_decode('added')
3251.6.3 by Adrian Wilkins
Simplified and fixed test code
412
        self.assertEqual('"'+fname+'"'+'\n', txt)
1185.85.52 by John Arbash Meinel
Updated cmd_added, which obviously had no tests, because it had a bug in it.
413
2823.2.2 by Daniel Watkins
Merged bzr.dev.
414
        self.run_bzr_decode('added', encoding='ascii', fail=True)
1185.85.52 by John Arbash Meinel
Updated cmd_added, which obviously had no tests, because it had a bug in it.
415
1185.85.53 by John Arbash Meinel
Updated cmd_root
416
    def test_root(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
417
        dirname = self.info['directory']
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
418
        url = urlutils.local_path_to_url(dirname)
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
419
        self.run_bzr_decode('root')
1185.85.53 by John Arbash Meinel
Updated cmd_root
420
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
421
        self.wt.bzrdir.sprout(url)
1185.85.53 by John Arbash Meinel
Updated cmd_root
422
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
423
        txt = self.run_bzr_decode('root', working_dir=dirname)
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
424
        self.failUnless(txt.endswith(dirname+'\n'))
1185.85.53 by John Arbash Meinel
Updated cmd_root
425
2823.2.2 by Daniel Watkins
Merged bzr.dev.
426
        txt = self.run_bzr_decode('root', encoding='ascii', fail=True,
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
427
                                  working_dir=dirname)
1185.85.53 by John Arbash Meinel
Updated cmd_root
428
1185.85.54 by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py
429
    def test_log(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
430
        fname = self.info['filename']
431
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
432
        txt = self.run_bzr_decode('log')
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
433
        self.assertNotEqual(-1, txt.find(self.info['committer']))
434
        self.assertNotEqual(-1, txt.find(self.info['message']))
1185.85.54 by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py
435
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
436
        txt = self.run_bzr_decode('log --verbose')
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
437
        # FIXME: iso-8859-2 test shouldn't be skipped here --vila 20090702
438
        self._check_OSX_can_roundtrip(self.info['filename'])
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
439
        self.assertNotEqual(-1, txt.find(fname))
1185.85.54 by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py
440
441
        # Make sure log doesn't fail even if we can't write out
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
442
        txt = self.run_bzr_decode('log --verbose', encoding='ascii')
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
443
        self.assertEqual(-1, txt.find(fname))
444
        self.assertNotEqual(-1, txt.find(fname.encode('ascii', 'replace')))
1185.85.54 by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py
445
1185.85.55 by John Arbash Meinel
Updated cmd_touching_revisions
446
    def test_touching_revisions(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
447
        fname = self.info['filename']
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
448
        txt = self.run_bzr_decode(['touching-revisions', fname])
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
449
        self._check_OSX_can_roundtrip(self.info['filename'])
1185.85.55 by John Arbash Meinel
Updated cmd_touching_revisions
450
        self.assertEqual(u'     3 added %s\n' % (fname,), txt)
451
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
452
        fname2 = self.info['filename'] + '2'
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
453
        self.wt.rename_one(fname, fname2)
454
        self.wt.commit(u'Renamed %s => %s' % (fname, fname2))
1185.85.55 by John Arbash Meinel
Updated cmd_touching_revisions
455
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
456
        txt = self.run_bzr_decode(['touching-revisions', fname2])
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
457
        expected_txt = (u'     3 added %s\n'
1185.85.55 by John Arbash Meinel
Updated cmd_touching_revisions
458
                        u'     4 renamed %s => %s\n'
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
459
                        % (fname, fname, fname2))
1185.85.55 by John Arbash Meinel
Updated cmd_touching_revisions
460
        self.assertEqual(expected_txt, txt)
461
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
462
        self.run_bzr_decode(['touching-revisions', fname2], encoding='ascii',
2823.2.2 by Daniel Watkins
Merged bzr.dev.
463
                            fail=True)
1185.85.55 by John Arbash Meinel
Updated cmd_touching_revisions
464
1185.85.56 by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py
465
    def test_ls(self):
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
466
        txt = self.run_bzr_decode('ls')
1830.3.10 by John Arbash Meinel
Don't compare direct output of ls, sort first
467
        self.assertEqual(sorted(['a', 'b', self.info['filename']]),
468
                         sorted(txt.splitlines()))
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
469
        txt = self.run_bzr_decode('ls --null')
1830.3.10 by John Arbash Meinel
Don't compare direct output of ls, sort first
470
        self.assertEqual(sorted(['', 'a', 'b', self.info['filename']]),
471
                         sorted(txt.split('\0')))
1185.85.56 by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py
472
2823.2.2 by Daniel Watkins
Merged bzr.dev.
473
        txt = self.run_bzr_decode('ls', encoding='ascii', fail=True)
474
        txt = self.run_bzr_decode('ls --null', encoding='ascii', fail=True)
1185.85.56 by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py
475
1185.85.57 by John Arbash Meinel
Updated cmd_unknowns
476
    def test_unknowns(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
477
        fname = self.info['filename'] + '2'
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
478
        self.build_tree_contents([(fname, 'unknown\n')])
1185.85.57 by John Arbash Meinel
Updated cmd_unknowns
479
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
480
        # TODO: jam 20060112 bzr unknowns is the only one which
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
481
        #       quotes paths do we really want it to?
3251.6.3 by Adrian Wilkins
Simplified and fixed test code
482
        #       awilkins 20080521 added and modified do it now as well
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
483
        txt = self.run_bzr_decode('unknowns')
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
484
        self._check_OSX_can_roundtrip(self.info['filename'])
1185.85.57 by John Arbash Meinel
Updated cmd_unknowns
485
        self.assertEqual(u'"%s"\n' % (fname,), txt)
486
2823.2.2 by Daniel Watkins
Merged bzr.dev.
487
        self.run_bzr_decode('unknowns', encoding='ascii', fail=True)
1185.85.57 by John Arbash Meinel
Updated cmd_unknowns
488
1185.85.58 by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names.
489
    def test_ignore(self):
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
490
        fname2 = self.info['filename'] + '2.txt'
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
491
        self.build_tree_contents([(fname2, 'ignored\n')])
1185.85.58 by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names.
492
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
493
        def check_unknowns(expected):
494
            self.assertEqual(expected, list(self.wt.unknowns()))
495
4498.4.3 by Vincent Ladeuil
Try to stop failing tests as late as possible on OSX.
496
        self._check_OSX_can_roundtrip(self.info['filename'])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
497
        check_unknowns([fname2])
1185.85.58 by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names.
498
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
499
        self.run_bzr_decode(['ignore', './' + fname2])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
500
        check_unknowns([])
1185.85.58 by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names.
501
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
502
        fname3 = self.info['filename'] + '3.txt'
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
503
        self.build_tree_contents([(fname3, 'unknown 3\n')])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
504
        check_unknowns([fname3])
1185.85.58 by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names.
505
506
        # Ignore should not care what the encoding is
507
        # (right now it doesn't print anything)
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
508
        self.run_bzr_decode(['ignore', fname3], encoding='ascii')
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
509
        check_unknowns([])
1185.85.59 by John Arbash Meinel
Adding extra tests for future corrections to WorkingTree.is_ignored()
510
511
        # Now try a wildcard match
1185.85.70 by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii.
512
        fname4 = self.info['filename'] + '4.txt'
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
513
        self.build_tree_contents([(fname4, 'unknown 4\n')])
514
        self.run_bzr_decode('ignore *.txt')
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
515
        check_unknowns([])
1185.85.53 by John Arbash Meinel
Updated cmd_root
516
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
517
        # and a different wildcard that matches everything
1185.85.59 by John Arbash Meinel
Adding extra tests for future corrections to WorkingTree.is_ignored()
518
        os.remove('.bzrignore')
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
519
        self.run_bzr_decode(['ignore', self.info['filename'] + '*'])
1836.2.2 by John Arbash Meinel
Cleanup the rest of the test_non_ascii suite to use internal apis.
520
        check_unknowns([])
1185.85.59 by John Arbash Meinel
Adding extra tests for future corrections to WorkingTree.is_ignored()
521
1816.1.1 by Alexander Belchenko
blackbox test for non-ascii behaviour of missing command
522
    def test_missing(self):
523
        # create empty tree as reference for missing
2823.2.1 by Daniel Watkins
Cleaned up tests.blackbox.test_non_ascii so it uses internals where appropriate.
524
        self.make_branch_and_tree('empty-tree')
1816.1.1 by Alexander Belchenko
blackbox test for non-ascii behaviour of missing command
525
526
        msg = self.info['message']
527
2823.2.3 by Daniel Watkins
Removed erroneous retcodes.
528
        txt = self.run_bzr_decode('missing empty-tree')
1816.1.1 by Alexander Belchenko
blackbox test for non-ascii behaviour of missing command
529
        self.assertNotEqual(-1, txt.find(self.info['committer']))
530
        self.assertNotEqual(-1, txt.find(msg))
531
532
        # Make sure missing doesn't fail even if we can't write out
2823.2.3 by Daniel Watkins
Removed erroneous retcodes.
533
        txt = self.run_bzr_decode('missing empty-tree', encoding='ascii')
1816.1.1 by Alexander Belchenko
blackbox test for non-ascii behaviour of missing command
534
        self.assertEqual(-1, txt.find(msg))
535
        self.assertNotEqual(-1, txt.find(msg.encode('ascii', 'replace')))
2904.3.1 by Lukáš Lalinský
Unicode-safe output from ``bzr info``.
536
537
    def test_info(self):
2904.3.2 by Lukáš Lalinský
More details in NEWS and use full self.run_bzr_decode name in the test.
538
        self.run_bzr_decode(['branch', u'.', self.info['directory']])
539
        self.run_bzr_decode(['info', self.info['directory']])
540
        self.run_bzr_decode(['info', self.info['directory']],
541
                            encoding='ascii')
3123.2.1 by Lukáš Lalinský
Use self.outf instead of sys.stdout in cmd_ignored.
542
543
    def test_ignored(self):
544
        fname = self.info['filename'] + '1.txt'
545
        self.build_tree_contents([(fname, 'ignored\n')])
546
        self.run_bzr(['ignore', fname])
547
        txt = self.run_bzr_decode(['ignored'])
548
        self.assertEqual(txt, '%-50s %s\n' % (fname, fname))
549
        txt = self.run_bzr_decode(['ignored'], encoding='ascii')
550
        fname = fname.encode('ascii', 'replace')
551
        self.assertEqual(txt, '%-50s %s\n' % (fname, fname))