43
44
if isinstance(args, basestring):
44
45
args = args.split()
47
return self.backtick(['python', self.BZRPATH,] + args,
50
return self.runcmd(['python', self.BZRPATH,] + args,
53
class TestCommands(ExternalBase):
55
def test_help_commands(self):
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):
56
105
self.runbzr('--help')
57
106
self.runbzr('help')
58
107
self.runbzr('help commands')
59
108
self.runbzr('help help')
60
109
self.runbzr('commit -h')
62
def test_init_branch(self):
112
class InitBranch(ExternalBase):
64
115
self.runbzr(['init'])
66
def test_whoami(self):
119
class UserIdentity(ExternalBase):
67
121
# this should always identify something, if only "john@localhost"
68
122
self.runbzr("whoami")
69
123
self.runbzr("whoami --email")
71
self.assertEquals(self.runbzr("whoami --email",
72
backtick=True).count('@'), 1)
74
def test_whoami_branch(self):
75
"""branch specific user identity works."""
77
f = file('.bzr/email', 'wt')
78
f.write('Branch Identity <branch@identi.ty>')
80
whoami = self.runbzr("whoami",backtick=True)
81
whoami_email = self.runbzr("whoami --email",backtick=True)
82
self.assertTrue(whoami.startswith('Branch Identity <branch@identi.ty>'))
83
self.assertTrue(whoami_email.startswith('branch@identi.ty'))
85
def test_invalid_commands(self):
124
self.assertEquals(self.backtick("bzr whoami --email").count('@'),
128
class InvalidCommands(ExternalBase):
86
130
self.runbzr("pants", retcode=1)
87
131
self.runbzr("--pants off", retcode=1)
88
132
self.runbzr("diff --message foo", retcode=1)
90
def test_empty_commit(self):
136
class EmptyCommit(ExternalBase):
91
138
self.runbzr("init")
92
139
self.build_tree(['hello.txt'])
93
140
self.runbzr("commit -m empty", retcode=1)
94
141
self.runbzr("add hello.txt")
95
142
self.runbzr("commit -m added")
97
def test_ignore_patterns(self):
146
class IgnorePatterns(ExternalBase):
98
148
from bzrlib.branch import Branch
100
150
b = Branch('.', init=True)
125
175
self.runbzr('ignore garh')
126
176
self.assertEquals(list(b.unknowns()), [])
127
177
assert file('.bzrignore', 'rb').read() == '*.blah\ngarh\n'
129
def test_revert(self):
134
file('hello', 'wt').write('foo')
135
self.runbzr('add hello')
136
self.runbzr('commit -m setup hello')
138
file('goodbye', 'wt').write('baz')
139
self.runbzr('add goodbye')
140
self.runbzr('commit -m setup goodbye')
142
file('hello', 'wt').write('bar')
143
file('goodbye', 'wt').write('qux')
144
self.runbzr('revert hello')
145
self.check_file_contents('hello', 'foo')
146
self.check_file_contents('goodbye', 'qux')
147
self.runbzr('revert')
148
self.check_file_contents('goodbye', 'baz')
150
os.mkdir('revertdir')
151
self.runbzr('add revertdir')
152
self.runbzr('commit -m f')
153
os.rmdir('revertdir')
154
self.runbzr('revert')
157
def skipped_test_mv_modes(self):
158
"""Test two modes of operation for mv"""
159
from bzrlib.branch import Branch
160
b = Branch('.', init=True)
161
self.build_tree(['a', 'c', 'subdir/'])
162
self.run_bzr('mv', 'a', 'b')
163
self.run_bzr('mv', 'b', 'subdir')
164
self.run_bzr('mv', 'subdir/b', 'a')
165
self.run_bzr('mv', 'a', 'b', 'subdir')
166
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
168
def test_main_version(self):
169
"""Check output from version command and master option is reasonable"""
170
# output is intentionally passed through to stdout so that we
171
# can see the version being tested
172
output = self.runbzr('version', backtick=1)
173
self.log('bzr version output:')
175
self.assert_(output.startswith('bzr (bazaar-ng) '))
176
self.assertNotEqual(output.index('Canonical'), -1)
177
# make sure --version is consistent
178
tmp_output = self.runbzr('--version', backtick=1)
179
self.log('bzr --version output:')
181
self.assertEquals(output, tmp_output)
183
182
class OldTests(ExternalBase):
184
183
# old tests moved from ./testbzr
186
185
from os import chdir, mkdir
187
186
from os.path import exists
355
def example_branch(test):
358
file('hello', 'wt').write('foo')
359
test.runbzr('add hello')
360
test.runbzr('commit -m setup hello')
362
file('goodbye', 'wt').write('baz')
363
test.runbzr('add goodbye')
364
test.runbzr('commit -m setup goodbye')
367
357
class RevertCommand(ExternalBase):
368
358
def runTest(self):
361
file('hello', 'wt').write('foo')
362
self.runbzr('add hello')
363
self.runbzr('commit -m setup hello')
370
365
file('hello', 'wt').write('bar')
371
file('goodbye', 'wt').write('qux')
372
366
self.runbzr('revert hello')
373
367
self.check_file_contents('hello', 'foo')
374
self.check_file_contents('goodbye', 'qux')
375
self.runbzr('revert')
376
self.check_file_contents('goodbye', 'baz')
379
class MergeCommand(ExternalBase):
381
from bzrlib.branch import Branch
387
self.runbzr('branch a b')
389
file('goodbye', 'wt').write('quux')
390
self.runbzr(['commit', '-m', "more u's are always good"])
393
file('hello', 'wt').write('quuux')
394
# We can't merge when there are in-tree changes
395
self.runbzr('merge ../b', retcode=1)
396
self.runbzr(['commit', '-m', "Like an epidemic of u's"])
397
self.runbzr('merge ../b')
398
self.check_file_contents('goodbye', 'quux')
399
# Merging a branch pulls its revision into the tree
402
a.get_revision_xml(b.last_patch())
403
print "Pending: %s" % a.pending_merges()
404
# assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
405
# % (a.pending_merges(), b.last_patch())