/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.1 by Vincent Ladeuil
Fix assert_ being deprecated by using assertTrue.
1
# Copyright (C) 2005-2011, 2016 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
720 by Martin Pool
- start moving external tests into the testsuite framework
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
720 by Martin Pool
- start moving external tests into the testsuite framework
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
720 by Martin Pool
- start moving external tests into the testsuite framework
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
720 by Martin Pool
- start moving external tests into the testsuite framework
16
1185.46.9 by Aaron Bentley
Added verbose option to bzr add, to list all ignored files.
17
# Mr. Smoketoomuch: I'm sorry?
18
# Mr. Bounder: You'd better cut down a little then.
19
# Mr. Smoketoomuch: Oh, I see! Smoke too much so I'd better cut down a little
20
#                   then!
720 by Martin Pool
- start moving external tests into the testsuite framework
21
22
"""Black-box tests for bzr.
23
24
These check that it behaves properly when it's invoked through the regular
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
25
command-line interface. This doesn't actually run a new interpreter but
6622.1.29 by Jelmer Vernooij
Fix some more tests.
26
rather starts again from the run_brz function.
720 by Martin Pool
- start moving external tests into the testsuite framework
27
"""
28
1393.1.45 by Martin Pool
doc
29
1185.33.14 by Martin Pool
doc
30
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
31
# Note: Please don't add new tests here, it's too big and bulky.  Instead add
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
32
# them into small suites in breezy.tests.blackbox.test_FOO for the particular
1512 by Robert Collins
Merge from Martin. Adjust check to work with HTTP again.
33
# UI command/aspect that is being tested.
1185.33.14 by Martin Pool
doc
34
35
1185.1.41 by Robert Collins
massive patch from Alexander Belchenko - many PEP8 fixes, removes unused function uuid
36
import os
1185.16.43 by Martin Pool
- clean up handling of option objects
37
import re
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
38
import sys
1161 by Martin Pool
- add test that 'bzr add' reports the files as they're added
39
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
40
import breezy
41
from breezy import (
1996.3.18 by John Arbash Meinel
Now that mkdtemp and rmtree are lazy, they should not be directly improted.
42
    osutils,
43
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
44
from breezy.branch import Branch
7490.61.1 by Jelmer Vernooij
Rename BzrCommandError to CommandError.
45
from breezy.errors import CommandError
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
46
from breezy.tests.http_utils import TestCaseWithWebserver
47
from breezy.tests.test_sftp_transport import TestCaseWithSFTPServer
48
from breezy.tests import TestCaseWithTransport
49
from breezy.workingtree import WorkingTree
1142 by Martin Pool
- remove dead code from blackbox tests (pychecker)
50
1185.65.29 by Robert Collins
Implement final review suggestions.
51
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
52
class TestCommands(TestCaseWithTransport):
1102 by Martin Pool
- merge test refactoring from robertc
53
54
    def test_invalid_commands(self):
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
55
        self.run_bzr("pants", retcode=3)
56
        self.run_bzr("--pants off", retcode=3)
57
        self.run_bzr("diff --message foo", retcode=3)
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
58
1102 by Martin Pool
- merge test refactoring from robertc
59
    def test_revert(self):
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
60
        self.run_bzr('init')
1102 by Martin Pool
- merge test refactoring from robertc
61
7143.15.2 by Jelmer Vernooij
Run autopep8.
62
        with open('hello', 'wt') as f:
63
            f.write('foo')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
64
        self.run_bzr('add hello')
65
        self.run_bzr('commit -m setup hello')
1102 by Martin Pool
- merge test refactoring from robertc
66
7143.15.2 by Jelmer Vernooij
Run autopep8.
67
        with open('goodbye', 'wt') as f:
68
            f.write('baz')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
69
        self.run_bzr('add goodbye')
70
        self.run_bzr('commit -m setup goodbye')
1092.2.18 by Robert Collins
merge from symlink branch
71
7143.15.2 by Jelmer Vernooij
Run autopep8.
72
        with open('hello', 'wt') as f:
73
            f.write('bar')
74
        with open('goodbye', 'wt') as f:
75
            f.write('qux')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
76
        self.run_bzr('revert hello')
6973.10.4 by Jelmer Vernooij
Update python3.passing.
77
        self.check_file_contents('hello', b'foo')
78
        self.check_file_contents('goodbye', b'qux')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
79
        self.run_bzr('revert')
6973.10.4 by Jelmer Vernooij
Update python3.passing.
80
        self.check_file_contents('goodbye', b'baz')
1102 by Martin Pool
- merge test refactoring from robertc
81
82
        os.mkdir('revertdir')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
83
        self.run_bzr('add revertdir')
84
        self.run_bzr('commit -m f')
1102 by Martin Pool
- merge test refactoring from robertc
85
        os.rmdir('revertdir')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
86
        self.run_bzr('revert')
1102 by Martin Pool
- merge test refactoring from robertc
87
4747.3.6 by Vincent Ladeuil
terminal_width can now returns None.
88
        if osutils.has_symlinks():
1185.31.49 by John Arbash Meinel
Some corrections using the new osutils.rename. **ALL TESTS PASS**
89
            os.symlink('/unlikely/to/exist', 'symlink')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
90
            self.run_bzr('add symlink')
91
            self.run_bzr('commit -m f')
1185.31.49 by John Arbash Meinel
Some corrections using the new osutils.rename. **ALL TESTS PASS**
92
            os.unlink('symlink')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
93
            self.run_bzr('revert')
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
94
            self.assertPathExists('symlink')
1185.31.49 by John Arbash Meinel
Some corrections using the new osutils.rename. **ALL TESTS PASS**
95
            os.unlink('symlink')
96
            os.symlink('a-different-path', 'symlink')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
97
            self.run_bzr('revert')
1185.31.49 by John Arbash Meinel
Some corrections using the new osutils.rename. **ALL TESTS PASS**
98
            self.assertEqual('/unlikely/to/exist',
99
                             os.readlink('symlink'))
100
        else:
101
            self.log("skipping revert symlink tests")
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
102
7143.15.2 by Jelmer Vernooij
Run autopep8.
103
        with open('hello', 'wt') as f:
104
            f.write('xyz')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
105
        self.run_bzr('commit -m xyz hello')
106
        self.run_bzr('revert -r 1 hello')
6973.10.4 by Jelmer Vernooij
Update python3.passing.
107
        self.check_file_contents('hello', b'foo')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
108
        self.run_bzr('revert hello')
6973.10.4 by Jelmer Vernooij
Update python3.passing.
109
        self.check_file_contents('hello', b'xyz')
1185.8.5 by Aaron Bentley
Fixed non-tree-root bug in branch, revert, merge
110
        os.chdir('revertdir')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
111
        self.run_bzr('revert')
1185.8.5 by Aaron Bentley
Fixed non-tree-root bug in branch, revert, merge
112
        os.chdir('..')
113
1092.1.39 by Robert Collins
merge from mpool
114
    def example_branch(test):
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
115
        test.run_bzr('init')
7143.15.2 by Jelmer Vernooij
Run autopep8.
116
        with open('hello', 'wt') as f:
117
            f.write('foo')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
118
        test.run_bzr('add hello')
119
        test.run_bzr('commit -m setup hello')
7143.15.2 by Jelmer Vernooij
Run autopep8.
120
        with open('goodbye', 'wt') as f:
121
            f.write('baz')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
122
        test.run_bzr('add goodbye')
123
        test.run_bzr('commit -m setup goodbye')
1092.1.39 by Robert Collins
merge from mpool
124
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
125
    def test_pull_verbose(self):
126
        """Pull changes from one branch to another and watch the output."""
127
128
        os.mkdir('a')
129
        os.chdir('a')
130
131
        self.example_branch()
132
133
        os.chdir('..')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
134
        self.run_bzr('branch a b')
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
135
        os.chdir('b')
7143.15.2 by Jelmer Vernooij
Run autopep8.
136
        with open('b', 'wb') as f:
137
            f.write(b'else\n')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
138
        self.run_bzr('add b')
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
139
        self.run_bzr(['commit', '-m', 'added b'])
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
140
141
        os.chdir('../a')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
142
        out = self.run_bzr('pull --verbose ../b')[0]
5784.1.1 by Martin Pool
Stop using failIf, failUnless, etc
143
        self.assertNotEqual(out.find('Added Revisions:'), -1)
144
        self.assertNotEqual(out.find('message:\n  added b'), -1)
145
        self.assertNotEqual(out.find('added b'), -1)
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
146
1185.32.4 by John Arbash Meinel
[merge] up-to-date against bzr.dev
147
        # Check that --overwrite --verbose prints out the removed entries
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
148
        self.run_bzr('commit -m foo --unchanged')
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
149
        os.chdir('../b')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
150
        self.run_bzr('commit -m baz --unchanged')
151
        self.run_bzr('pull ../a', retcode=3)
152
        out = self.run_bzr('pull --overwrite --verbose ../a')[0]
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
153
154
        remove_loc = out.find('Removed Revisions:')
5784.1.1 by Martin Pool
Stop using failIf, failUnless, etc
155
        self.assertNotEqual(remove_loc, -1)
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
156
        added_loc = out.find('Added Revisions:')
5784.1.1 by Martin Pool
Stop using failIf, failUnless, etc
157
        self.assertNotEqual(added_loc, -1)
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
158
159
        removed_message = out.find('message:\n  baz')
5784.1.1 by Martin Pool
Stop using failIf, failUnless, etc
160
        self.assertNotEqual(removed_message, -1)
161
        self.assertTrue(remove_loc < removed_message < added_loc)
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
162
163
        added_message = out.find('message:\n  foo')
5784.1.1 by Martin Pool
Stop using failIf, failUnless, etc
164
        self.assertNotEqual(added_message, -1)
165
        self.assertTrue(added_loc < added_message)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
166
1185.12.11 by Aaron Bentley
Made pull only save the parent location if it is unset, or on --remember
167
    def test_locations(self):
168
        """Using and remembering different locations"""
169
        os.mkdir('a')
170
        os.chdir('a')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
171
        self.run_bzr('init')
172
        self.run_bzr('commit -m unchanged --unchanged')
173
        self.run_bzr('pull', retcode=3)
174
        self.run_bzr('merge', retcode=3)
175
        self.run_bzr('branch . ../b')
1185.12.11 by Aaron Bentley
Made pull only save the parent location if it is unset, or on --remember
176
        os.chdir('../b')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
177
        self.run_bzr('pull')
178
        self.run_bzr('branch . ../c')
179
        self.run_bzr('pull ../c')
180
        self.run_bzr('merge')
1185.12.11 by Aaron Bentley
Made pull only save the parent location if it is unset, or on --remember
181
        os.chdir('../a')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
182
        self.run_bzr('pull ../b')
183
        self.run_bzr('pull')
184
        self.run_bzr('pull ../c')
185
        self.run_bzr('branch ../c ../d')
1996.3.18 by John Arbash Meinel
Now that mkdtemp and rmtree are lazy, they should not be directly improted.
186
        osutils.rmtree('../c')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
187
        self.run_bzr('pull')
1185.12.11 by Aaron Bentley
Made pull only save the parent location if it is unset, or on --remember
188
        os.chdir('../b')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
189
        self.run_bzr('pull')
1185.12.11 by Aaron Bentley
Made pull only save the parent location if it is unset, or on --remember
190
        os.chdir('../d')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
191
        self.run_bzr('pull', retcode=3)
192
        self.run_bzr('pull ../a --remember')
193
        self.run_bzr('pull')
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
194
1185.3.20 by Martin Pool
- run_bzr_captured also includes logged errors in
195
    def test_unknown_command(self):
196
        """Handling of unknown command."""
2552.2.4 by Vincent Ladeuil
Merge bzr.dev and resolve conflits. (good use case for an enhanced merge
197
        out, err = self.run_bzr('fluffy-badger', retcode=3)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
198
        self.assertEqual(out, '')
1185.3.20 by Martin Pool
- run_bzr_captured also includes logged errors in
199
        err.index('unknown command')
1185.14.9 by Aaron Bentley
Added tests for 'bzr conflicts', 'bzr resolve'
200
1185.35.4 by Aaron Bentley
Implemented remerge
201
    def create_conflicts(self):
202
        """Create a conflicted tree"""
1185.14.9 by Aaron Bentley
Added tests for 'bzr conflicts', 'bzr resolve'
203
        os.mkdir('base')
204
        os.chdir('base')
7143.15.2 by Jelmer Vernooij
Run autopep8.
205
        with open('hello', 'wb') as f:
206
            f.write(b"hi world")
207
        with open('answer', 'wb') as f:
208
            f.write(b"42")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
209
        self.run_bzr('init')
210
        self.run_bzr('add')
211
        self.run_bzr('commit -m base')
212
        self.run_bzr('branch . ../other')
213
        self.run_bzr('branch . ../this')
1185.14.9 by Aaron Bentley
Added tests for 'bzr conflicts', 'bzr resolve'
214
        os.chdir('../other')
7143.15.2 by Jelmer Vernooij
Run autopep8.
215
        with open('hello', 'wb') as f:
216
            f.write(b"Hello.")
217
        with open('answer', 'wb') as f:
218
            f.write(b"Is anyone there?")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
219
        self.run_bzr('commit -m other')
1185.14.9 by Aaron Bentley
Added tests for 'bzr conflicts', 'bzr resolve'
220
        os.chdir('../this')
7143.15.2 by Jelmer Vernooij
Run autopep8.
221
        with open('hello', 'wb') as f:
222
            f.write(b"Hello, world")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
223
        self.run_bzr('mv answer question')
7143.15.2 by Jelmer Vernooij
Run autopep8.
224
        with open('question', 'wb') as f:
225
            f.write(b"What do you get when you multiply six"
226
                    b"times nine?")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
227
        self.run_bzr('commit -m this')
1185.35.4 by Aaron Bentley
Implemented remerge
228
1185.65.6 by Aaron Bentley
Fixed inner merges in status
229
    def test_status(self):
230
        os.mkdir('branch1')
231
        os.chdir('branch1')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
232
        self.run_bzr('init')
233
        self.run_bzr('commit --unchanged --message f')
234
        self.run_bzr('branch . ../branch2')
235
        self.run_bzr('branch . ../branch3')
236
        self.run_bzr('commit --unchanged --message peter')
1185.65.6 by Aaron Bentley
Fixed inner merges in status
237
        os.chdir('../branch2')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
238
        self.run_bzr('merge ../branch1')
239
        self.run_bzr('commit --unchanged --message pumpkin')
1185.65.6 by Aaron Bentley
Fixed inner merges in status
240
        os.chdir('../branch3')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
241
        self.run_bzr('merge ../branch2')
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
242
        message = self.run_bzr('status')[0]
1185.65.6 by Aaron Bentley
Fixed inner merges in status
243
1185.35.4 by Aaron Bentley
Implemented remerge
244
    def test_conflicts(self):
245
        """Handling of merge conflicts"""
246
        self.create_conflicts()
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
247
        self.run_bzr('merge ../other --show-base', retcode=1)
6973.7.5 by Jelmer Vernooij
s/file/open.
248
        with open('hello', 'r') as f:
249
            conflict_text = f.read()
6614.1.1 by Vincent Ladeuil
Fix assert_ being deprecated by using assertTrue.
250
        self.assertTrue('<<<<<<<' in conflict_text)
251
        self.assertTrue('>>>>>>>' in conflict_text)
252
        self.assertTrue('=======' in conflict_text)
253
        self.assertTrue('|||||||' in conflict_text)
254
        self.assertTrue('hi world' in conflict_text)
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
255
        self.run_bzr('revert')
256
        self.run_bzr('resolve --all')
257
        self.run_bzr('merge ../other', retcode=1)
6973.7.5 by Jelmer Vernooij
s/file/open.
258
        with open('hello', 'r') as f:
259
            conflict_text = f.read()
6614.1.1 by Vincent Ladeuil
Fix assert_ being deprecated by using assertTrue.
260
        self.assertTrue('|||||||' not in conflict_text)
261
        self.assertTrue('hi world' not in conflict_text)
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
262
        result = self.run_bzr('conflicts')[0]
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
263
        self.assertEqual(result, "Text conflict in hello\nText conflict in"
7143.15.2 by Jelmer Vernooij
Run autopep8.
264
                         " question\n")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
265
        result = self.run_bzr('status')[0]
6614.1.1 by Vincent Ladeuil
Fix assert_ being deprecated by using assertTrue.
266
        self.assertTrue("conflicts:\n  Text conflict in hello\n"
7143.15.2 by Jelmer Vernooij
Run autopep8.
267
                        "  Text conflict in question\n" in result, result)
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
268
        self.run_bzr('resolve hello')
269
        result = self.run_bzr('conflicts')[0]
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
270
        self.assertEqual(result, "Text conflict in question\n")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
271
        self.run_bzr('commit -m conflicts', retcode=3)
272
        self.run_bzr('resolve --all')
273
        result = self.run_bzr('conflicts')[0]
274
        self.run_bzr('commit -m conflicts')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
275
        self.assertEqual(result, "")
1185.3.20 by Martin Pool
- run_bzr_captured also includes logged errors in
276
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
277
    def test_push(self):
278
        # create a source branch
279
        os.mkdir('my-branch')
280
        os.chdir('my-branch')
281
        self.example_branch()
282
283
        # with no push target, fail
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
284
        self.run_bzr('push', retcode=3)
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
285
        # with an explicit target work
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
286
        self.run_bzr('push ../output-branch')
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
287
        # with an implicit target work
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
288
        self.run_bzr('push')
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
289
        # nothing missing
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
290
        self.run_bzr('missing ../output-branch')
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
291
        # advance this branch
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
292
        self.run_bzr('commit --unchanged -m unchanged')
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
293
294
        os.chdir('../output-branch')
1185.50.6 by John Arbash Meinel
Fixed a broken test from my 'push updates local working tree' fix
295
        # There is no longer a difference as long as we have
296
        # access to the working tree
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
297
        self.run_bzr('diff')
1185.50.6 by John Arbash Meinel
Fixed a broken test from my 'push updates local working tree' fix
298
299
        # But we should be missing a revision
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
300
        self.run_bzr('missing ../my-branch', retcode=1)
1185.50.6 by John Arbash Meinel
Fixed a broken test from my 'push updates local working tree' fix
301
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
302
        # diverge the branches
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
303
        self.run_bzr('commit --unchanged -m unchanged')
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
304
        os.chdir('../my-branch')
305
        # cannot push now
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
306
        self.run_bzr('push', retcode=3)
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
307
        # and there are difference
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
308
        self.run_bzr('missing ../output-branch', retcode=1)
309
        self.run_bzr('missing --verbose ../output-branch', retcode=1)
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
310
        # but we can force a push
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
311
        self.run_bzr('push --overwrite')
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
312
        # nothing missing
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
313
        self.run_bzr('missing ../output-branch')
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
314
1495 by Robert Collins
Add a --create-prefix to the new push command.
315
        # pushing to a new dir with no parent should fail
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
316
        self.run_bzr('push ../missing/new-branch', retcode=3)
1495 by Robert Collins
Add a --create-prefix to the new push command.
317
        # unless we provide --create-prefix
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
318
        self.run_bzr('push --create-prefix ../missing/new-branch')
1495 by Robert Collins
Add a --create-prefix to the new push command.
319
        # nothing missing
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
320
        self.run_bzr('missing ../missing/new-branch')
1490 by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1.
321
1185.31.3 by John Arbash Meinel
Fix ExternalCommand to not run random files in the current directory, unless it is truly in BZRPATH
322
    def test_external_command(self):
1588.1.1 by Martin Pool
Supress "hello from test-command" noise from test_external_command
323
        """Test that external commands can be run by setting the path
324
        """
6622.1.29 by Jelmer Vernooij
Fix some more tests.
325
        # We don't at present run brz in a subprocess for blackbox tests, and so
1588.1.1 by Martin Pool
Supress "hello from test-command" noise from test_external_command
326
        # don't really capture stdout, only the internal python stream.
327
        # Therefore we don't use a subcommand that produces any output or does
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
328
        # anything -- we just check that it can be run successfully.
1185.31.3 by John Arbash Meinel
Fix ExternalCommand to not run random files in the current directory, unless it is truly in BZRPATH
329
        cmd_name = 'test-command'
330
        if sys.platform == 'win32':
331
            cmd_name += '.bat'
5570.3.9 by Vincent Ladeuil
More use cases for overrideEnv, _cleanEnvironment *may* contain too much variables now.
332
        self.overrideEnv('BZRPATH', None)
333
6973.7.5 by Jelmer Vernooij
s/file/open.
334
        f = open(cmd_name, 'wb')
5570.3.9 by Vincent Ladeuil
More use cases for overrideEnv, _cleanEnvironment *may* contain too much variables now.
335
        if sys.platform == 'win32':
6973.7.5 by Jelmer Vernooij
s/file/open.
336
            f.write(b'@echo off\n')
5570.3.9 by Vincent Ladeuil
More use cases for overrideEnv, _cleanEnvironment *may* contain too much variables now.
337
        else:
6973.7.5 by Jelmer Vernooij
s/file/open.
338
            f.write(b'#!/bin/sh\n')
5570.3.9 by Vincent Ladeuil
More use cases for overrideEnv, _cleanEnvironment *may* contain too much variables now.
339
        # f.write('echo Hello from test-command')
340
        f.close()
6619.3.14 by Jelmer Vernooij
Convert some octal numbers to new notations.
341
        os.chmod(cmd_name, 0o755)
5570.3.9 by Vincent Ladeuil
More use cases for overrideEnv, _cleanEnvironment *may* contain too much variables now.
342
343
        # It should not find the command in the local
344
        # directory by default, since it is not in my path
345
        self.run_bzr(cmd_name, retcode=3)
346
347
        # Now put it into my path
348
        self.overrideEnv('BZRPATH', '.')
349
        self.run_bzr(cmd_name)
350
351
        # Make sure empty path elements are ignored
352
        self.overrideEnv('BZRPATH', os.pathsep)
353
        self.run_bzr(cmd_name, retcode=3)
1185.31.3 by John Arbash Meinel
Fix ExternalCommand to not run random files in the current directory, unless it is truly in BZRPATH
354
355
1092.2.6 by Robert Collins
symlink support updated to work
356
def listdir_sorted(dir):
6619.3.18 by Jelmer Vernooij
Run 2to3 idioms fixer.
357
    L = sorted(os.listdir(dir))
1092.2.6 by Robert Collins
symlink support updated to work
358
    return L
1185.3.20 by Martin Pool
- run_bzr_captured also includes logged errors in
359
1092.2.12 by Robert Collins
merge from HEAD
360
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
361
class OldTests(TestCaseWithTransport):
1092.1.39 by Robert Collins
merge from mpool
362
    """old tests moved from ./testbzr."""
363
1102 by Martin Pool
- merge test refactoring from robertc
364
    def test_bzr(self):
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
365
        from os import chdir, mkdir
366
        from os.path import exists
367
368
        progress = self.log
369
370
        progress("basic branch creation")
904 by Martin Pool
- more selftest external-command fixes
371
        mkdir('branch1')
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
372
        chdir('branch1')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
373
        self.run_bzr('init')
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
374
2823.1.6 by Vincent Ladeuil
Redo minor fix.
375
        self.assertIsSameRealPath(self.run_bzr('root')[0].rstrip(),
4747.3.6 by Vincent Ladeuil
terminal_width can now returns None.
376
                                  osutils.pathjoin(self.test_dir, 'branch1'))
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
377
378
        progress("status of new file")
379
6973.7.5 by Jelmer Vernooij
s/file/open.
380
        with open('test.txt', 'wt') as f:
7045.2.2 by Jelmer Vernooij
Fix whoami test.
381
            f.write('hello world!\n')
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
382
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
383
        self.assertEqual(self.run_bzr('unknowns')[0], 'test.txt\n')
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
384
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
385
        out = self.run_bzr("status")[0]
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
386
        self.assertEqual(out, 'unknown:\n  test.txt\n')
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
387
6973.7.5 by Jelmer Vernooij
s/file/open.
388
        with open('test2.txt', 'wt') as f:
389
            f.write('goodbye cruel world...\n')
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
390
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
391
        out = self.run_bzr("status test.txt")[0]
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
392
        self.assertEqual(out, "unknown:\n  test.txt\n")
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
393
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
394
        out = self.run_bzr("status")[0]
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
395
        self.assertEqual(out, ("unknown:\n" "  test.txt\n" "  test2.txt\n"))
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
396
397
        os.unlink('test2.txt')
398
399
        progress("command aliases")
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
400
        out = self.run_bzr("st")[0]
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
401
        self.assertEqual(out, ("unknown:\n" "  test.txt\n"))
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
402
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
403
        out = self.run_bzr("stat")[0]
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
404
        self.assertEqual(out, ("unknown:\n" "  test.txt\n"))
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
405
406
        progress("command help")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
407
        self.run_bzr("help st")
408
        self.run_bzr("help")
409
        self.run_bzr("help commands")
410
        self.run_bzr("help slartibartfast", retcode=3)
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
411
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
412
        out = self.run_bzr("help ci")[0]
2666.1.1 by Ian Clatworthy
Bazaar User Reference generated from online help
413
        out.index('Aliases:  ci, checkin\n')
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
414
6973.7.5 by Jelmer Vernooij
s/file/open.
415
        with open('hello.txt', 'wt') as f:
416
            f.write('some nice new content\n')
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
417
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
418
        self.run_bzr("add hello.txt")
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
419
6973.7.5 by Jelmer Vernooij
s/file/open.
420
        with open('msg.tmp', 'wt') as f:
421
            f.write('this is my new commit\nand it has multiple lines, for fun')
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
422
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
423
        self.run_bzr('commit -F msg.tmp')
424
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
425
        self.assertEqual(self.run_bzr('revno')[0], '1\n')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
426
        self.run_bzr('export -r 1 export-1.tmp')
427
        self.run_bzr('export export.tmp')
428
429
        self.run_bzr('log')
430
        self.run_bzr('log -v')
431
        self.run_bzr('log -v --forward')
432
        self.run_bzr('log -m', retcode=3)
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
433
        log_out = self.run_bzr('log -m commit')[0]
7045.4.8 by Jelmer Vernooij
Fix another 128 tests on python 3.
434
        self.assertTrue("this is my new commit\n  and" in log_out)
435
        self.assertTrue("rename nested" not in log_out)
436
        self.assertTrue('revision-id' not in log_out)
7143.15.2 by Jelmer Vernooij
Run autopep8.
437
        self.assertTrue(
438
            'revision-id' in self.run_bzr('log --show-ids -m commit')[0])
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
439
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
440
        log_out = self.run_bzr('log --line')[0]
1692.3.5 by Robert Collins
Merge integration, fixing test failure in test_too_much due to terminal width changing.
441
        # determine the widest line we want
4747.3.6 by Vincent Ladeuil
terminal_width can now returns None.
442
        max_width = osutils.terminal_width()
443
        if max_width is not None:
444
            for line in log_out.splitlines():
6614.1.1 by Vincent Ladeuil
Fix assert_ being deprecated by using assertTrue.
445
                self.assertTrue(len(line) <= max_width - 1, len(line))
446
        self.assertTrue("this is my new commit and" not in log_out)
447
        self.assertTrue("this is my new commit" in log_out)
1185.12.25 by Aaron Bentley
Added one-line log format
448
736 by Martin Pool
- move old blackbox code from testbzr into bzrlib.selftest.blackbox
449
        progress("file with spaces in name")
450
        mkdir('sub directory')
7143.15.2 by Jelmer Vernooij
Run autopep8.
451
        with open('sub directory/file with spaces ', 'wt') as f:
452
            f.write('see how this works\n')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
453
        self.run_bzr('add .')
454
        self.run_bzr('diff', retcode=1)
455
        self.run_bzr('commit -m add-spaces')
456
        self.run_bzr('check')
457
458
        self.run_bzr('log')
459
        self.run_bzr('log --forward')
460
461
        self.run_bzr('info')
1092.1.35 by Robert Collins
merge from mpool up to rev 1110
462
4747.3.6 by Vincent Ladeuil
terminal_width can now returns None.
463
        if osutils.has_symlinks():
1092.2.6 by Robert Collins
symlink support updated to work
464
            progress("symlinks")
465
            mkdir('symlinks')
466
            chdir('symlinks')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
467
            self.run_bzr('init')
1092.2.6 by Robert Collins
symlink support updated to work
468
            os.symlink("NOWHERE1", "link1")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
469
            self.run_bzr('add link1')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
470
            self.assertEqual(self.run_bzr('unknowns')[0], '')
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
471
            self.run_bzr(['commit', '-m', '1: added symlink link1'])
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
472
1092.2.6 by Robert Collins
symlink support updated to work
473
            mkdir('d1')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
474
            self.run_bzr('add d1')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
475
            self.assertEqual(self.run_bzr('unknowns')[0], '')
1092.2.6 by Robert Collins
symlink support updated to work
476
            os.symlink("NOWHERE2", "d1/link2")
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
477
            self.assertEqual(self.run_bzr('unknowns')[0], 'd1/link2\n')
1092.2.6 by Robert Collins
symlink support updated to work
478
            # is d1/link2 found when adding d1
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
479
            self.run_bzr('add d1')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
480
            self.assertEqual(self.run_bzr('unknowns')[0], '')
1092.2.6 by Robert Collins
symlink support updated to work
481
            os.symlink("NOWHERE3", "d1/link3")
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
482
            self.assertEqual(self.run_bzr('unknowns')[0], 'd1/link3\n')
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
483
            self.run_bzr(['commit', '-m', '2: added dir, symlink'])
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
484
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
485
            self.run_bzr('rename d1 d2')
486
            self.run_bzr('move d2/link2 .')
487
            self.run_bzr('move link1 d2')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
488
            self.assertEqual(os.readlink("./link2"), "NOWHERE2")
489
            self.assertEqual(os.readlink("d2/link1"), "NOWHERE1")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
490
            self.run_bzr('add d2/link3')
491
            self.run_bzr('diff', retcode=1)
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
492
            self.run_bzr(['commit', '-m',
493
                          '3: rename of dir, move symlinks, add link3'])
494
1092.2.6 by Robert Collins
symlink support updated to work
495
            os.unlink("link2")
496
            os.symlink("TARGET 2", "link2")
497
            os.unlink("d2/link1")
498
            os.symlink("TARGET 1", "d2/link1")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
499
            self.run_bzr('diff', retcode=1)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
500
            self.assertEqual(self.run_bzr("relpath d2/link1")[0], "d2/link1\n")
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
501
            self.run_bzr(['commit', '-m', '4: retarget of two links'])
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
502
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
503
            self.run_bzr('remove --keep d2/link1')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
504
            self.assertEqual(self.run_bzr('unknowns')[0], 'd2/link1\n')
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
505
            self.run_bzr(['commit', '-m', '5: remove d2/link1'])
2292.1.23 by Marius Kruger
Revert test_too_much.py and just do the minimum te get the tests to pass.
506
            # try with the rm alias
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
507
            self.run_bzr('add d2/link1')
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
508
            self.run_bzr(['commit', '-m', '6: add d2/link1'])
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
509
            self.run_bzr('rm --keep d2/link1')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
510
            self.assertEqual(self.run_bzr('unknowns')[0], 'd2/link1\n')
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
511
            self.run_bzr(['commit', '-m', '7: remove d2/link1'])
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
512
1092.2.6 by Robert Collins
symlink support updated to work
513
            os.mkdir("d1")
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
514
            self.run_bzr('add d1')
515
            self.run_bzr('rename d2/link3 d1/link3new')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
516
            self.assertEqual(self.run_bzr('unknowns')[0], 'd2/link1\n')
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
517
            self.run_bzr(['commit', '-m',
518
                          '8: remove d2/link1, move/rename link3'])
519
520
            self.run_bzr('check')
521
522
            self.run_bzr('export -r 1 exp1.tmp')
1092.2.6 by Robert Collins
symlink support updated to work
523
            chdir("exp1.tmp")
7143.15.2 by Jelmer Vernooij
Run autopep8.
524
            self.assertEqual(listdir_sorted("."), ["link1"])
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
525
            self.assertEqual(os.readlink("link1"), "NOWHERE1")
1092.2.6 by Robert Collins
symlink support updated to work
526
            chdir("..")
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
527
528
            self.run_bzr('export -r 2 exp2.tmp')
1092.2.6 by Robert Collins
symlink support updated to work
529
            chdir("exp2.tmp")
7143.15.2 by Jelmer Vernooij
Run autopep8.
530
            self.assertEqual(listdir_sorted("."), ["d1", "link1"])
1092.2.6 by Robert Collins
symlink support updated to work
531
            chdir("..")
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
532
533
            self.run_bzr('export -r 3 exp3.tmp')
1092.2.6 by Robert Collins
symlink support updated to work
534
            chdir("exp3.tmp")
7143.15.2 by Jelmer Vernooij
Run autopep8.
535
            self.assertEqual(listdir_sorted("."), ["d2", "link2"])
536
            self.assertEqual(listdir_sorted("d2"), ["link1", "link3"])
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
537
            self.assertEqual(os.readlink("d2/link1"), "NOWHERE1")
6809.1.1 by Martin
Apply 2to3 ws_comma fixer
538
            self.assertEqual(os.readlink("link2"), "NOWHERE2")
1092.2.6 by Robert Collins
symlink support updated to work
539
            chdir("..")
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
540
541
            self.run_bzr('export -r 4 exp4.tmp')
1092.2.6 by Robert Collins
symlink support updated to work
542
            chdir("exp4.tmp")
7143.15.2 by Jelmer Vernooij
Run autopep8.
543
            self.assertEqual(listdir_sorted("."), ["d2", "link2"])
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
544
            self.assertEqual(os.readlink("d2/link1"), "TARGET 1")
6809.1.1 by Martin
Apply 2to3 ws_comma fixer
545
            self.assertEqual(os.readlink("link2"), "TARGET 2")
7143.15.2 by Jelmer Vernooij
Run autopep8.
546
            self.assertEqual(listdir_sorted("d2"), ["link1", "link3"])
1092.2.6 by Robert Collins
symlink support updated to work
547
            chdir("..")
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
548
549
            self.run_bzr('export -r 5 exp5.tmp')
1092.2.6 by Robert Collins
symlink support updated to work
550
            chdir("exp5.tmp")
7143.15.2 by Jelmer Vernooij
Run autopep8.
551
            self.assertEqual(listdir_sorted("."), ["d2", "link2"])
6614.1.1 by Vincent Ladeuil
Fix assert_ being deprecated by using assertTrue.
552
            self.assertTrue(os.path.islink("link2"))
7143.15.2 by Jelmer Vernooij
Run autopep8.
553
            self.assertTrue(listdir_sorted("d2") == ["link3"])
1092.2.6 by Robert Collins
symlink support updated to work
554
            chdir("..")
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
555
556
            self.run_bzr('export -r 8 exp6.tmp')
1092.2.6 by Robert Collins
symlink support updated to work
557
            chdir("exp6.tmp")
7143.15.2 by Jelmer Vernooij
Run autopep8.
558
            self.assertEqual(listdir_sorted("."), ["d1", "d2", "link2"])
559
            self.assertEqual(listdir_sorted("d1"), ["link3new"])
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
560
            self.assertEqual(listdir_sorted("d2"), [])
561
            self.assertEqual(os.readlink("d1/link3new"), "NOWHERE3")
1092.2.6 by Robert Collins
symlink support updated to work
562
            chdir("..")
563
        else:
564
            progress("skipping symlink tests")
1400.1.1 by Robert Collins
implement a basic test for the ui branch command from http servers
565
566
1524.1.1 by Robert Collins
Test sftp with relative, absolute-in-homedir and absolute-not-in-homedir
567
class RemoteTests(object):
6622.1.29 by Jelmer Vernooij
Fix some more tests.
568
    """Test brz ui commands against remote branches."""
1400.1.1 by Robert Collins
implement a basic test for the ui branch command from http servers
569
570
    def test_branch(self):
571
        os.mkdir('from')
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
572
        wt = self.make_branch_and_tree('from')
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
573
        branch = wt.branch
574
        wt.commit('empty commit for nonsense', allow_pointless=True)
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
575
        url = self.get_readonly_url('from')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
576
        self.run_bzr(['branch', url, 'to'])
1400.1.1 by Robert Collins
implement a basic test for the ui branch command from http servers
577
        branch = Branch.open('to')
6165.4.6 by Jelmer Vernooij
Avoid more uses of revision_history.
578
        self.assertEqual(1, branch.last_revision_info()[0])
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
579
        # the branch should be set in to to from
580
        self.assertEqual(url + '/', branch.get_parent())
1185.16.48 by mbp at sourcefrog
- more refactoring of and tests for option parsing
581
1442.1.64 by Robert Collins
Branch.open_containing now returns a tuple (Branch, relative-path).
582
    def test_log(self):
583
        self.build_tree(['branch/', 'branch/file'])
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
584
        self.run_bzr('init branch')[0]
585
        self.run_bzr('add branch/file')[0]
586
        self.run_bzr('commit -m foo branch')[0]
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
587
        url = self.get_readonly_url('branch/file')
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
588
        output = self.run_bzr('log %s' % url)[0]
1185.35.17 by Aaron Bentley
Added branch nicks to long-format logs
589
        self.assertEqual(8, len(output.split('\n')))
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
590
1510 by Robert Collins
Merge from mpool, adjusting check to retain HTTP support.
591
    def test_check(self):
592
        self.build_tree(['branch/', 'branch/file'])
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
593
        self.run_bzr('init branch')[0]
594
        self.run_bzr('add branch/file')[0]
595
        self.run_bzr('commit -m foo branch')[0]
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
596
        url = self.get_readonly_url('branch/')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
597
        self.run_bzr(['check', url])
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
598
1563.1.6 by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls.
599
    def test_push(self):
600
        # create a source branch
601
        os.mkdir('my-branch')
602
        os.chdir('my-branch')
603
        self.run_bzr('init')
7143.15.2 by Jelmer Vernooij
Run autopep8.
604
        with open('hello', 'wt') as f:
605
            f.write('foo')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
606
        self.run_bzr('add hello')
607
        self.run_bzr('commit -m setup')
1563.1.6 by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls.
608
609
        # with an explicit target work
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
610
        self.run_bzr(['push', self.get_url('output-branch')])
1563.1.6 by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls.
611
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
612
1524.1.1 by Robert Collins
Test sftp with relative, absolute-in-homedir and absolute-not-in-homedir
613
class HTTPTests(TestCaseWithWebserver, RemoteTests):
614
    """Test various commands against a HTTP server."""
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
615
616
1524.1.1 by Robert Collins
Test sftp with relative, absolute-in-homedir and absolute-not-in-homedir
617
class SFTPTestsAbsolute(TestCaseWithSFTPServer, RemoteTests):
618
    """Test various commands against a SFTP server using abs paths."""
619
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
620
1524.1.1 by Robert Collins
Test sftp with relative, absolute-in-homedir and absolute-not-in-homedir
621
class SFTPTestsAbsoluteSibling(TestCaseWithSFTPServer, RemoteTests):
622
    """Test various commands against a SFTP server using abs paths."""
623
624
    def setUp(self):
625
        super(SFTPTestsAbsoluteSibling, self).setUp()
626
        self._override_home = '/dev/noone/runs/tests/here'
627
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
628
1524.1.1 by Robert Collins
Test sftp with relative, absolute-in-homedir and absolute-not-in-homedir
629
class SFTPTestsRelative(TestCaseWithSFTPServer, RemoteTests):
630
    """Test various commands against a SFTP server using homedir rel paths."""
631
632
    def setUp(self):
633
        super(SFTPTestsRelative, self).setUp()
634
        self._get_remote_is_absolute = False