19
19
"""Black-box tests for bzr.
21
21
These check that it behaves properly when it's invoked through the regular
22
command-line interface. This doesn't actually run a new interpreter but
23
rather starts again from the run_bzr function.
22
command-line interface.
27
25
from cStringIO import StringIO
31
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
33
32
from bzrlib.branch import Branch
34
from bzrlib.errors import BzrCommandError
35
33
from bzrlib.osutils import has_symlinks
36
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
37
34
from bzrlib.selftest.HTTPTestUtil import TestCaseWithWebserver
104
101
self.runbzr("add hello.txt")
105
102
self.runbzr("commit -m added")
107
def test_empty_commit_message(self):
109
file('foo.c', 'wt').write('int main() {}')
110
self.runbzr(['add', 'foo.c'])
111
self.runbzr(["commit", "-m", ""] , retcode=1)
113
104
def test_ignore_patterns(self):
114
105
from bzrlib.branch import Branch
196
187
self.run_bzr_captured(['mv', 'a', 'c', 'subdir'])
197
188
self.run_bzr_captured(['mv', 'subdir/a', 'subdir/newa'])
199
191
def test_main_version(self):
200
192
"""Check output from version command and master option is reasonable"""
201
193
# output is intentionally passed through to stdout so that we
308
300
a.get_revision_xml(b.last_revision())
309
301
self.log('pending merges: %s', a.pending_merges())
310
302
# assert a.pending_merges() == [b.last_revision()], "Assertion %s %s" \
311
# % (a.pending_merges(), b.last_patch())
313
def test_merge_with_missing_file(self):
314
"""Merge handles missing file conflicts"""
318
print >> file('sub/a.txt', 'wb'), "hello"
319
print >> file('b.txt', 'wb'), "hello"
320
print >> file('sub/c.txt', 'wb'), "hello"
323
self.runbzr(('commit', '-m', 'added a'))
324
self.runbzr('branch . ../b')
325
print >> file('sub/a.txt', 'ab'), "there"
326
print >> file('b.txt', 'ab'), "there"
327
print >> file('sub/c.txt', 'ab'), "there"
328
self.runbzr(('commit', '-m', 'Added there'))
329
os.unlink('sub/a.txt')
330
os.unlink('sub/c.txt')
333
self.runbzr(('commit', '-m', 'Removed a.txt'))
335
print >> file('sub/a.txt', 'ab'), "something"
336
print >> file('b.txt', 'ab'), "something"
337
print >> file('sub/c.txt', 'ab'), "something"
338
self.runbzr(('commit', '-m', 'Modified a.txt'))
339
self.runbzr('merge ../a/')
340
assert os.path.exists('sub/a.txt.THIS')
341
assert os.path.exists('sub/a.txt.BASE')
343
self.runbzr('merge ../b/')
344
assert os.path.exists('sub/a.txt.OTHER')
345
assert os.path.exists('sub/a.txt.BASE')
303
# % (a.pending_merges(), b.last_revision())
347
305
def test_merge_with_missing_file(self):
348
306
"""Merge handles missing file conflicts"""
427
385
self.runbzr('commit -m blah8 --unchanged')
428
386
self.runbzr('pull ../b')
429
387
self.runbzr('pull ../b')
431
def test_locations(self):
432
"""Using and remembering different locations"""
436
self.runbzr('commit -m unchanged --unchanged')
437
self.runbzr('pull', retcode=1)
438
self.runbzr('merge', retcode=1)
439
self.runbzr('branch . ../b')
442
self.runbzr('branch . ../c')
443
self.runbzr('pull ../c')
446
self.runbzr('pull ../b')
448
self.runbzr('pull ../c')
449
self.runbzr('branch ../c ../d')
450
shutil.rmtree('../c')
455
self.runbzr('pull', retcode=1)
456
self.runbzr('pull ../a --remember')
459
389
def test_add_reports(self):
460
390
"""add command prints the names of added files."""
475
405
self.assertEquals(out, '')
476
406
err.index('unknown command')
478
def test_conflicts(self):
479
"""Handling of merge conflicts"""
482
file('hello', 'wb').write("hi world")
483
file('answer', 'wb').write("42")
486
self.runbzr('commit -m base')
487
self.runbzr('branch . ../other')
488
self.runbzr('branch . ../this')
490
file('hello', 'wb').write("Hello.")
491
file('answer', 'wb').write("Is anyone there?")
492
self.runbzr('commit -m other')
494
file('hello', 'wb').write("Hello, world")
495
self.runbzr('mv answer question')
496
file('question', 'wb').write("What do you get when you multiply six"
498
self.runbzr('commit -m this')
499
self.runbzr('merge ../other')
500
result = self.runbzr('conflicts', backtick=1)
501
self.assertEquals(result, "hello\nquestion\n")
502
result = self.runbzr('status', backtick=1)
503
assert "conflicts:\n hello\n question\n" in result, result
504
self.runbzr('resolve hello')
505
result = self.runbzr('conflicts', backtick=1)
506
self.assertEquals(result, "question\n")
507
self.runbzr('commit -m conflicts', retcode=1)
508
self.runbzr('resolve --all')
509
result = self.runbzr('conflicts', backtick=1)
510
self.runbzr('commit -m conflicts')
511
self.assertEquals(result, "")
513
409
def listdir_sorted(dir):
514
410
L = os.listdir(dir)