44
43
if isinstance(args, basestring):
45
44
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):
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):
105
56
self.runbzr('--help')
106
57
self.runbzr('help')
107
58
self.runbzr('help commands')
108
59
self.runbzr('help help')
109
60
self.runbzr('commit -h')
112
class InitBranch(ExternalBase):
62
def test_init_branch(self):
115
64
self.runbzr(['init'])
119
class UserIdentity(ExternalBase):
66
def test_whoami(self):
121
67
# this should always identify something, if only "john@localhost"
122
68
self.runbzr("whoami")
123
69
self.runbzr("whoami --email")
124
self.assertEquals(self.backtick("bzr whoami --email").count('@'),
128
class InvalidCommands(ExternalBase):
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):
130
86
self.runbzr("pants", retcode=1)
131
87
self.runbzr("--pants off", retcode=1)
132
88
self.runbzr("diff --message foo", retcode=1)
136
class EmptyCommit(ExternalBase):
90
def test_empty_commit(self):
138
91
self.runbzr("init")
139
92
self.build_tree(['hello.txt'])
140
93
self.runbzr("commit -m empty", retcode=1)
141
94
self.runbzr("add hello.txt")
142
95
self.runbzr("commit -m added")
146
class IgnorePatterns(ExternalBase):
97
def test_ignore_patterns(self):
148
98
from bzrlib.branch import Branch
150
100
b = Branch('.', init=True)
175
125
self.runbzr('ignore garh')
176
126
self.assertEquals(list(b.unknowns()), [])
177
127
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)
182
183
class OldTests(ExternalBase):
183
184
# old tests moved from ./testbzr
185
186
from os import chdir, mkdir
186
187
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')
357
367
class RevertCommand(ExternalBase):
358
368
def runTest(self):
361
file('hello', 'wt').write('foo')
362
self.runbzr('add hello')
363
self.runbzr('commit -m setup hello')
365
370
file('hello', 'wt').write('bar')
371
file('goodbye', 'wt').write('qux')
366
372
self.runbzr('revert hello')
367
373
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())