49
class TestCommands(ExternalBase):
51
def test_help_commands(self):
56
class MvCommand(BzrTestBase):
58
"""Test two modes of operation for mv"""
59
b = Branch('.', init=True)
60
self.build_tree(['a', 'c', 'subdir/'])
61
self.run_bzr('mv', 'a', 'b')
62
self.run_bzr('mv', 'b', 'subdir')
63
self.run_bzr('mv', 'subdir/b', 'a')
64
self.run_bzr('mv', 'a', 'b', 'subdir')
65
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
69
class TestVersion(BzrTestBase):
70
"""Check output from version command and master option is reasonable"""
72
# output is intentionally passed through to stdout so that we
73
# can see the version being tested
74
from cStringIO import StringIO
77
sys.stdout = tmp_out = StringIO()
79
self.run_bzr('version')
83
output = tmp_out.getvalue()
84
self.log('bzr version output:')
87
self.assert_(output.startswith('bzr (bazaar-ng) '))
88
self.assertNotEqual(output.index('Canonical'), -1)
90
# make sure --version is consistent
92
sys.stdout = tmp_out = StringIO()
94
self.run_bzr('--version')
98
self.log('bzr --version output:')
99
self.log(tmp_out.getvalue())
101
self.assertEquals(output, tmp_out.getvalue())
107
class HelpCommands(ExternalBase):
52
109
self.runbzr('--help')
53
110
self.runbzr('help')
54
111
self.runbzr('help commands')
55
112
self.runbzr('help help')
56
113
self.runbzr('commit -h')
58
def test_init_branch(self):
116
class InitBranch(ExternalBase):
59
119
self.runbzr(['init'])
61
def test_whoami(self):
123
class UserIdentity(ExternalBase):
62
125
# this should always identify something, if only "john@localhost"
63
126
self.runbzr("whoami")
64
127
self.runbzr("whoami --email")
77
141
self.assertTrue(whoami.startswith('Branch Identity <branch@identi.ty>'))
78
142
self.assertTrue(whoami_email.startswith('branch@identi.ty'))
80
def test_invalid_commands(self):
145
class InvalidCommands(ExternalBase):
81
147
self.runbzr("pants", retcode=1)
82
148
self.runbzr("--pants off", retcode=1)
83
149
self.runbzr("diff --message foo", retcode=1)
85
def test_empty_commit(self):
153
class EmptyCommit(ExternalBase):
86
155
self.runbzr("init")
87
156
self.build_tree(['hello.txt'])
88
157
self.runbzr("commit -m empty", retcode=1)
89
158
self.runbzr("add hello.txt")
90
159
self.runbzr("commit -m added")
92
def test_ignore_patterns(self):
163
class IgnorePatterns(ExternalBase):
93
165
from bzrlib.branch import Branch
95
167
b = Branch('.', init=True)
120
192
self.runbzr('ignore garh')
121
193
self.assertEquals(list(b.unknowns()), [])
122
194
assert file('.bzrignore', 'rb').read() == '*.blah\ngarh\n'
124
def test_revert(self):
128
file('hello', 'wt').write('foo')
129
self.runbzr('add hello')
130
self.runbzr('commit -m setup hello')
132
file('goodbye', 'wt').write('baz')
133
self.runbzr('add goodbye')
134
self.runbzr('commit -m setup goodbye')
136
file('hello', 'wt').write('bar')
137
file('goodbye', 'wt').write('qux')
138
self.runbzr('revert hello')
139
self.check_file_contents('hello', 'foo')
140
self.check_file_contents('goodbye', 'qux')
141
self.runbzr('revert')
142
self.check_file_contents('goodbye', 'baz')
144
os.mkdir('revertdir')
145
self.runbzr('add revertdir')
146
self.runbzr('commit -m f')
147
os.rmdir('revertdir')
148
self.runbzr('revert')
150
def skipped_test_mv_modes(self):
151
"""Test two modes of operation for mv"""
152
from bzrlib.branch import Branch
153
b = Branch('.', init=True)
154
self.build_tree(['a', 'c', 'subdir/'])
155
self.run_bzr('mv', 'a', 'b')
156
self.run_bzr('mv', 'b', 'subdir')
157
self.run_bzr('mv', 'subdir/b', 'a')
158
self.run_bzr('mv', 'a', 'b', 'subdir')
159
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
161
def test_main_version(self):
162
"""Check output from version command and master option is reasonable"""
163
# output is intentionally passed through to stdout so that we
164
# can see the version being tested
165
output = self.runbzr('version', backtick=1)
166
self.log('bzr version output:')
168
self.assert_(output.startswith('bzr (bazaar-ng) '))
169
self.assertNotEqual(output.index('Canonical'), -1)
170
# make sure --version is consistent
171
tmp_output = self.runbzr('--version', backtick=1)
172
self.log('bzr --version output:')
174
self.assertEquals(output, tmp_output)
176
def example_branch(test):
178
file('hello', 'wt').write('foo')
179
test.runbzr('add hello')
180
test.runbzr('commit -m setup hello')
181
file('goodbye', 'wt').write('baz')
182
test.runbzr('add goodbye')
183
test.runbzr('commit -m setup goodbye')
185
def test_revert(self):
186
self.example_branch()
187
file('hello', 'wt').write('bar')
188
file('goodbye', 'wt').write('qux')
189
self.runbzr('revert hello')
190
self.check_file_contents('hello', 'foo')
191
self.check_file_contents('goodbye', 'qux')
192
self.runbzr('revert')
193
self.check_file_contents('goodbye', 'baz')
195
def test_merge(self):
196
from bzrlib.branch import Branch
202
self.example_branch()
204
self.runbzr('branch a b')
206
file('goodbye', 'wt').write('quux')
207
self.runbzr(['commit', '-m', "more u's are always good"])
210
file('hello', 'wt').write('quuux')
211
# We can't merge when there are in-tree changes
212
self.runbzr('merge ../b', retcode=1)
213
self.runbzr(['commit', '-m', "Like an epidemic of u's"])
214
self.runbzr('merge ../b')
215
self.check_file_contents('goodbye', 'quux')
216
# Merging a branch pulls its revision into the tree
219
a.get_revision_xml(b.last_patch())
221
self.log('pending merges: %s', a.pending_merges())
222
# assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
223
# % (a.pending_merges(), b.last_patch())
226
def test_add_reports(self):
227
"""add command prints the names of added files."""
228
b = Branch('.', init=True)
229
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
231
from cStringIO import StringIO
234
ret = self.apply_redirected(None, out, None,
237
self.assertEquals(ret, 0)
239
# the ordering is not defined at the moment
240
results = sorted(out.getvalue().rstrip('\n').split('\n'))
241
self.assertEquals(['added dir',
247
199
class OldTests(ExternalBase):
248
"""old tests moved from ./testbzr."""
200
# old tests moved from ./testbzr
251
202
from os import chdir, mkdir
252
203
from os.path import exists