[Pkg-bazaar-commits] ./bzr/unstable r898: - add new runbzr method for external tests
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:21:23 UTC 2009
------------------------------------------------------------
revno: 898
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-07-11 16:31:36 +1000
message:
- add new runbzr method for external tests
modified:
bzrlib/selftest/blackbox.py
-------------- next part --------------
=== modified file 'bzrlib/selftest/blackbox.py'
--- a/bzrlib/selftest/blackbox.py 2005-07-11 03:40:02 +0000
+++ b/bzrlib/selftest/blackbox.py 2005-07-11 06:31:36 +0000
@@ -31,54 +31,72 @@
from unittest import TestCase
from bzrlib.selftest import TestBase, InTempDir
+
+
+class ExternalBase(TestBase):
+ def runbzr(self, args):
+ try:
+ import shutil
+ from subprocess import call
+ except ImportError, e:
+ _need_subprocess()
+ raise
+
+ if isinstance(args, basestring):
+ args = args.split()
+
+ return self.runcmd(['python', self.BZRPATH,] + args)
+
+
+
class TestVersion(TestBase):
def runTest(self):
# output is intentionally passed through to stdout so that we
# can see the version being tested
- self.runcmd(['bzr', 'version'])
+ self.runbzr(['version'])
class HelpCommands(TestBase):
def runTest(self):
- self.runcmd('bzr --help')
- self.runcmd('bzr help')
- self.runcmd('bzr help commands')
- self.runcmd('bzr help help')
- self.runcmd('bzr commit -h')
+ self.runbzr('--help')
+ self.runbzr('help')
+ self.runbzr('help commands')
+ self.runbzr('help help')
+ self.runbzr('commit -h')
class InitBranch(InTempDir):
def runTest(self):
import os
- self.runcmd(['bzr', 'init'])
+ self.runbzr(['init'])
class UserIdentity(InTempDir):
def runTest(self):
# this should always identify something, if only "john at localhost"
- self.runcmd("bzr whoami")
- self.runcmd("bzr whoami --email")
+ self.runbzr("whoami")
+ self.runbzr("whoami --email")
self.assertEquals(self.backtick("bzr whoami --email").count('@'),
1)
class InvalidCommands(InTempDir):
def runTest(self):
- self.runcmd("bzr pants", retcode=1)
- self.runcmd("bzr --pants off", retcode=1)
- self.runcmd("bzr diff --message foo", retcode=1)
+ self.runbzr("pants", retcode=1)
+ self.runbzr("--pants off", retcode=1)
+ self.runbzr("diff --message foo", retcode=1)
class EmptyCommit(InTempDir):
def runTest(self):
- self.runcmd("bzr init")
+ self.runbzr("init")
self.build_tree(['hello.txt'])
- self.runcmd("bzr commit -m empty", retcode=1)
- self.runcmd("bzr add hello.txt")
- self.runcmd("bzr commit -m added")
+ self.runbzr("commit -m empty", retcode=1)
+ self.runbzr("add hello.txt")
+ self.runbzr("commit -m added")
@@ -96,7 +114,7 @@
progress("basic branch creation")
runcmd(['mkdir', 'branch1'])
chdir('branch1')
- runcmd('bzr init')
+ runbzr('init')
self.assertEquals(backtick('bzr root').rstrip(),
os.path.join(self.test_dir, 'branch1'))
@@ -143,26 +161,26 @@
" test.txt\n")
progress("command help")
- runcmd("bzr help st")
- runcmd("bzr help")
- runcmd("bzr help commands")
- runcmd("bzr help slartibartfast", 1)
+ runbzr("help st")
+ runbzr("help")
+ runbzr("help commands")
+ runbzr("help slartibartfast", 1)
out = backtick("bzr help ci")
out.index('aliases: ')
progress("can't rename unversioned file")
- runcmd("bzr rename test.txt new-test.txt", 1)
+ runbzr("rename test.txt new-test.txt", 1)
progress("adding a file")
- runcmd("bzr add test.txt")
+ runbzr("add test.txt")
assert backtick("bzr unknowns") == ''
assert backtick("bzr status --all") == ("added:\n"
" test.txt\n")
progress("rename newly-added file")
- runcmd("bzr rename test.txt hello.txt")
+ runbzr("rename test.txt hello.txt")
assert os.path.exists("hello.txt")
assert not os.path.exists("test.txt")
@@ -173,13 +191,13 @@
progress("more complex renames")
os.mkdir("sub1")
- runcmd("bzr rename hello.txt sub1", 1)
- runcmd("bzr rename hello.txt sub1/hello.txt", 1)
- runcmd("bzr move hello.txt sub1", 1)
+ runbzr("rename hello.txt sub1", 1)
+ runbzr("rename hello.txt sub1/hello.txt", 1)
+ runbzr("move hello.txt sub1", 1)
- runcmd("bzr add sub1")
- runcmd("bzr rename sub1 sub2")
- runcmd("bzr move hello.txt sub2")
+ runbzr("add sub1")
+ runbzr("rename sub1 sub2")
+ runbzr("move hello.txt sub2")
assert backtick("bzr relpath sub2/hello.txt") == os.path.join("sub2", "hello.txt\n")
assert exists("sub2")
@@ -187,31 +205,31 @@
assert not exists("sub1")
assert not exists("hello.txt")
- runcmd(['bzr', 'commit', '-m', 'commit with some things moved to subdirs'])
+ runbzr(['commit', '-m', 'commit with some things moved to subdirs'])
mkdir("sub1")
- runcmd('bzr add sub1')
- runcmd('bzr move sub2/hello.txt sub1')
+ runbzr('add sub1')
+ runbzr('move sub2/hello.txt sub1')
assert not exists('sub2/hello.txt')
assert exists('sub1/hello.txt')
- runcmd('bzr move sub2 sub1')
+ runbzr('move sub2 sub1')
assert not exists('sub2')
assert exists('sub1/sub2')
- runcmd(['bzr', 'commit', '-m', 'rename nested subdirectories'])
+ runbzr(['commit', '-m', 'rename nested subdirectories'])
chdir('sub1/sub2')
self.assertEquals(backtick('bzr root')[:-1],
os.path.join(self.test_dir, 'branch1'))
- runcmd('bzr move ../hello.txt .')
+ runbzr('move ../hello.txt .')
assert exists('./hello.txt')
assert backtick('bzr relpath hello.txt') == os.path.join('sub1', 'sub2', 'hello.txt\n')
assert backtick('bzr relpath ../../sub1/sub2/hello.txt') == os.path.join('sub1', 'sub2', 'hello.txt\n')
- runcmd(['bzr', 'commit', '-m', 'move to parent directory'])
+ runbzr(['commit', '-m', 'move to parent directory'])
chdir('..')
assert backtick('bzr relpath sub2/hello.txt') == os.path.join('sub1', 'sub2', 'hello.txt\n')
- runcmd('bzr move sub2/hello.txt .')
+ runbzr('move sub2/hello.txt .')
assert exists('hello.txt')
f = file('hello.txt', 'wt')
@@ -222,29 +240,29 @@
f.write('this is my new commit\n')
f.close()
- runcmd('bzr commit -F msg.tmp')
+ runbzr('commit -F msg.tmp')
assert backtick('bzr revno') == '5\n'
- runcmd('bzr export -r 5 export-5.tmp')
- runcmd('bzr export export.tmp')
+ runbzr('export -r 5 export-5.tmp')
+ runbzr('export export.tmp')
- runcmd('bzr log')
- runcmd('bzr log -v')
+ runbzr('log')
+ runbzr('log -v')
progress("file with spaces in name")
mkdir('sub directory')
file('sub directory/file with spaces ', 'wt').write('see how this works\n')
- runcmd('bzr add .')
- runcmd('bzr diff')
- runcmd('bzr commit -m add-spaces')
- runcmd('bzr check')
-
- runcmd('bzr log')
- runcmd('bzr log --forward')
-
- runcmd('bzr info')
+ runbzr('add .')
+ runbzr('diff')
+ runbzr('commit -m add-spaces')
+ runbzr('check')
+
+ runbzr('log')
+ runbzr('log --forward')
+
+ runbzr('info')
@@ -255,25 +273,25 @@
chdir('..')
progress('branch')
# Can't create a branch if it already exists
- runcmd('bzr branch branch1', retcode=1)
+ runbzr('branch branch1', retcode=1)
# Can't create a branch if its parent doesn't exist
- runcmd('bzr branch /unlikely/to/exist', retcode=1)
- runcmd('bzr branch branch1 branch2')
+ runbzr('branch /unlikely/to/exist', retcode=1)
+ runbzr('branch branch1 branch2')
progress("pull")
chdir('branch1')
- runcmd('bzr pull', retcode=1)
- runcmd('bzr pull ../branch2')
+ runbzr('pull', retcode=1)
+ runbzr('pull ../branch2')
chdir('.bzr')
- runcmd('bzr pull')
- runcmd('bzr commit --unchanged -m empty')
- runcmd('bzr pull')
+ runbzr('pull')
+ runbzr('commit --unchanged -m empty')
+ runbzr('pull')
chdir('../../branch2')
- runcmd('bzr pull')
- runcmd('bzr commit --unchanged -m empty')
+ runbzr('pull')
+ runbzr('commit --unchanged -m empty')
chdir('../branch1')
- runcmd('bzr commit --unchanged -m empty')
- runcmd('bzr pull', retcode=1)
+ runbzr('commit --unchanged -m empty')
+ runbzr('pull', retcode=1)
chdir ('..')
progress('status after remove')
@@ -289,19 +307,19 @@
# at /vrac/python/bazaar-ng/bzrlib/diff.py:286 in compare_trees()
# see ~/.bzr.log for debug information
chdir('status-after-remove')
- runcmd('bzr init')
+ runbzr('init')
file('a', 'w').write('foo')
- runcmd('bzr add a')
- runcmd(['bzr', 'commit', '-m', 'add a'])
- runcmd('bzr remove a')
- runcmd('bzr status')
+ runbzr('add a')
+ runbzr(['commit', '-m', 'add a'])
+ runbzr('remove a')
+ runbzr('status')
chdir('..')
progress('ignore patterns')
mkdir('ignorebranch')
chdir('ignorebranch')
- runcmd('bzr init')
+ runbzr('init')
assert backtick('bzr unknowns') == ''
file('foo.tmp', 'wt').write('tmp files are ignored')
@@ -309,20 +327,20 @@
file('foo.c', 'wt').write('int main() {}')
assert backtick('bzr unknowns') == 'foo.c\n'
- runcmd('bzr add foo.c')
+ runbzr('add foo.c')
assert backtick('bzr unknowns') == ''
# 'ignore' works when creating the .bzignore file
file('foo.blah', 'wt').write('blah')
assert backtick('bzr unknowns') == 'foo.blah\n'
- runcmd('bzr ignore *.blah')
+ runbzr('ignore *.blah')
assert backtick('bzr unknowns') == ''
assert file('.bzrignore', 'rb').read() == '*.blah\n'
# 'ignore' works when then .bzrignore file already exists
file('garh', 'wt').write('garh')
assert backtick('bzr unknowns') == 'garh\n'
- runcmd('bzr ignore garh')
+ runbzr('ignore garh')
assert backtick('bzr unknowns') == ''
assert file('.bzrignore', 'rb').read() == '*.blah\ngarh\n'
@@ -334,22 +352,22 @@
progress("recursive and non-recursive add")
mkdir('no-recurse')
chdir('no-recurse')
- runcmd('bzr init')
+ runbzr('init')
mkdir('foo')
fp = os.path.join('foo', 'test.txt')
f = file(fp, 'w')
f.write('hello!\n')
f.close()
- runcmd('bzr add --no-recurse foo')
- runcmd('bzr file-id foo')
- runcmd('bzr file-id ' + fp, 1) # not versioned yet
- runcmd('bzr commit -m add-dir-only')
-
- runcmd('bzr file-id ' + fp, 1) # still not versioned
-
- runcmd('bzr add foo')
- runcmd('bzr file-id ' + fp)
- runcmd('bzr commit -m add-sub-file')
+ runbzr('add --no-recurse foo')
+ runbzr('file-id foo')
+ runbzr('file-id ' + fp, 1) # not versioned yet
+ runbzr('commit -m add-dir-only')
+
+ runbzr('file-id ' + fp, 1) # still not versioned
+
+ runbzr('add foo')
+ runbzr('file-id ' + fp)
+ runbzr('commit -m add-sub-file')
chdir('..')
@@ -357,14 +375,14 @@
class RevertCommand(InTempDir):
def runTest(self):
- self.runcmd('bzr init')
+ self.runbzr('init')
file('hello', 'wt').write('foo')
- self.runcmd('bzr add hello')
- self.runcmd('bzr commit -m setup hello')
+ self.runbzr('add hello')
+ self.runbzr('commit -m setup hello')
file('hello', 'wt').write('bar')
- self.runcmd('bzr revert hello')
+ self.runbzr('revert hello')
self.check_file_contents('hello', 'foo')
More information about the Pkg-bazaar-commits
mailing list