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