44
42
if isinstance(args, basestring):
45
43
args = args.split()
47
return self.runcmd(['python', self.BZRPATH,] + args,
52
class MvCommand(BzrTestBase):
54
"""Test two modes of operation for mv"""
55
b = Branch('.', init=True)
56
self.build_tree(['a', 'c', 'subdir/'])
57
self.run_bzr('mv', 'a', 'b')
58
self.run_bzr('mv', 'b', 'subdir')
59
self.run_bzr('mv', 'subdir/b', 'a')
60
self.run_bzr('mv', 'a', 'b', 'subdir')
61
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
65
class TestVersion(BzrTestBase):
66
"""Check output from version command and master option is reasonable"""
68
# output is intentionally passed through to stdout so that we
69
# can see the version being tested
70
from cStringIO import StringIO
73
sys.stdout = tmp_out = StringIO()
75
self.run_bzr('version')
79
output = tmp_out.getvalue()
80
self.log('bzr version output:')
83
self.assert_(output.startswith('bzr (bazaar-ng) '))
84
self.assertNotEqual(output.index('Canonical'), -1)
86
# make sure --version is consistent
88
sys.stdout = tmp_out = StringIO()
90
self.run_bzr('--version')
94
self.log('bzr --version output:')
95
self.log(tmp_out.getvalue())
97
self.assertEquals(output, tmp_out.getvalue())
103
class HelpCommands(ExternalBase):
46
return self.backtick(['python', self.BZRPATH,] + args,
49
return self.runcmd(['python', self.BZRPATH,] + args,
52
class TestCommands(ExternalBase):
54
def test_help_commands(self):
105
55
self.runbzr('--help')
106
56
self.runbzr('help')
107
57
self.runbzr('help commands')
108
58
self.runbzr('help help')
109
59
self.runbzr('commit -h')
112
class InitBranch(ExternalBase):
61
def test_init_branch(self):
115
63
self.runbzr(['init'])
119
class UserIdentity(ExternalBase):
65
def test_whoami(self):
121
66
# this should always identify something, if only "john@localhost"
122
67
self.runbzr("whoami")
123
68
self.runbzr("whoami --email")
124
self.assertEquals(self.backtick("bzr whoami --email").count('@'),
128
class InvalidCommands(ExternalBase):
70
self.assertEquals(self.runbzr("whoami --email",
71
backtick=True).count('@'), 1)
73
def test_whoami_branch(self):
74
"""branch specific user identity works."""
76
f = file('.bzr/email', 'wt')
77
f.write('Branch Identity <branch@identi.ty>')
79
whoami = self.runbzr("whoami",backtick=True)
80
whoami_email = self.runbzr("whoami --email",backtick=True)
81
self.assertTrue(whoami.startswith('Branch Identity <branch@identi.ty>'))
82
self.assertTrue(whoami_email.startswith('branch@identi.ty'))
84
def test_invalid_commands(self):
130
85
self.runbzr("pants", retcode=1)
131
86
self.runbzr("--pants off", retcode=1)
132
87
self.runbzr("diff --message foo", retcode=1)
136
class EmptyCommit(ExternalBase):
89
def test_empty_commit(self):
138
90
self.runbzr("init")
139
91
self.build_tree(['hello.txt'])
140
92
self.runbzr("commit -m empty", retcode=1)
141
93
self.runbzr("add hello.txt")
142
94
self.runbzr("commit -m added")
146
class IgnorePatterns(ExternalBase):
96
def test_ignore_patterns(self):
148
97
from bzrlib.branch import Branch
150
99
b = Branch('.', init=True)
175
124
self.runbzr('ignore garh')
176
125
self.assertEquals(list(b.unknowns()), [])
177
126
assert file('.bzrignore', 'rb').read() == '*.blah\ngarh\n'
128
def test_revert(self):
133
file('hello', 'wt').write('foo')
134
self.runbzr('add hello')
135
self.runbzr('commit -m setup hello')
137
file('goodbye', 'wt').write('baz')
138
self.runbzr('add goodbye')
139
self.runbzr('commit -m setup goodbye')
141
file('hello', 'wt').write('bar')
142
file('goodbye', 'wt').write('qux')
143
self.runbzr('revert hello')
144
self.check_file_contents('hello', 'foo')
145
self.check_file_contents('goodbye', 'qux')
146
self.runbzr('revert')
147
self.check_file_contents('goodbye', 'baz')
149
os.mkdir('revertdir')
150
self.runbzr('add revertdir')
151
self.runbzr('commit -m f')
152
os.rmdir('revertdir')
153
self.runbzr('revert')
156
def skipped_test_mv_modes(self):
157
"""Test two modes of operation for mv"""
158
from bzrlib.branch import Branch
159
b = Branch('.', init=True)
160
self.build_tree(['a', 'c', 'subdir/'])
161
self.run_bzr('mv', 'a', 'b')
162
self.run_bzr('mv', 'b', 'subdir')
163
self.run_bzr('mv', 'subdir/b', 'a')
164
self.run_bzr('mv', 'a', 'b', 'subdir')
165
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
167
def test_main_version(self):
168
"""Check output from version command and master option is reasonable"""
169
# output is intentionally passed through to stdout so that we
170
# can see the version being tested
171
output = self.runbzr('version', backtick=1)
172
self.log('bzr version output:')
174
self.assert_(output.startswith('bzr (bazaar-ng) '))
175
self.assertNotEqual(output.index('Canonical'), -1)
176
# make sure --version is consistent
177
tmp_output = self.runbzr('--version', backtick=1)
178
self.log('bzr --version output:')
180
self.assertEquals(output, tmp_output)
182
182
class OldTests(ExternalBase):
183
183
# old tests moved from ./testbzr
185
185
from os import chdir, mkdir
186
186
from os.path import exists
354
def example_branch(test):
357
file('hello', 'wt').write('foo')
358
test.runbzr('add hello')
359
test.runbzr('commit -m setup hello')
361
file('goodbye', 'wt').write('baz')
362
test.runbzr('add goodbye')
363
test.runbzr('commit -m setup goodbye')
357
366
class RevertCommand(ExternalBase):
358
367
def runTest(self):
361
file('hello', 'wt').write('foo')
362
self.runbzr('add hello')
363
self.runbzr('commit -m setup hello')
365
369
file('hello', 'wt').write('bar')
370
file('goodbye', 'wt').write('qux')
366
371
self.runbzr('revert hello')
367
372
self.check_file_contents('hello', 'foo')
373
self.check_file_contents('goodbye', 'qux')
374
self.runbzr('revert')
375
self.check_file_contents('goodbye', 'baz')
378
class MergeCommand(ExternalBase):
380
from bzrlib.branch import Branch
381
from bzrlib.commands import run_bzr
389
self.runbzr('branch a b')
391
file('goodbye', 'wt').write('quux')
392
self.runbzr(['commit', '-m', "more u's are always good"])
395
file('hello', 'wt').write('quuux')
396
# We can't merge when there are in-tree changes
397
self.runbzr('merge ../b', retcode=1)
398
self.runbzr(['commit', '-m', "Like an epidemic of u's"])
399
self.runbzr('merge ../b')
400
self.check_file_contents('goodbye', 'quux')
401
# Merging a branch pulls its revision into the tree
404
a.get_revision_xml(b.last_patch())
406
self.log('pending merges: %s', a.pending_merges())
407
# assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
408
# % (a.pending_merges(), b.last_patch())