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.
24
This always reinvokes bzr through a new Python interpreter, which is a
25
bit inefficient but arguably tests in a way more representative of how
26
it's normally invoked.
22
command-line interface. This doesn't actually run a new interpreter but
23
rather starts again from the run_bzr function.
29
27
from cStringIO import StringIO
33
from bzrlib.branch import Branch
34
from bzrlib.errors import BzrCommandError
35
from bzrlib.osutils import has_symlinks
35
36
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
36
from bzrlib.branch import Branch
37
from bzrlib.selftest.HTTPTestUtil import TestCaseWithWebserver
39
40
class ExternalBase(TestCaseInTempDir):
103
104
self.runbzr("add hello.txt")
104
105
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)
106
113
def test_ignore_patterns(self):
107
114
from bzrlib.branch import Branch
189
196
self.run_bzr_captured(['mv', 'a', 'c', 'subdir'])
190
197
self.run_bzr_captured(['mv', 'subdir/a', 'subdir/newa'])
193
199
def test_main_version(self):
194
200
"""Check output from version command and master option is reasonable"""
195
201
# output is intentionally passed through to stdout so that we
421
427
self.runbzr('commit -m blah8 --unchanged')
422
428
self.runbzr('pull ../b')
423
429
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')
425
459
def test_add_reports(self):
426
460
"""add command prints the names of added files."""
441
475
self.assertEquals(out, '')
442
476
err.index('unknown command')
447
if hasattr(os, 'symlink'):
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, "")
452
513
def listdir_sorted(dir):
453
514
L = os.listdir(dir)
721
782
progress("skipping symlink tests")
785
class HttpTests(TestCaseWithWebserver):
786
"""Test bzr ui commands against remote branches."""
788
def test_branch(self):
790
branch = Branch.initialize('from')
791
branch.commit('empty commit for nonsense', allow_pointless=True)
792
url = self.get_remote_url('from')
793
self.run_bzr('branch', url, 'to')
794
branch = Branch.open('to')
795
self.assertEqual(1, len(branch.revision_history()))