3
# Copyright (C) 2005 Canonical Ltd
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
"""External black-box test for bzr.
22
This always runs bzr as an external process to try to catch bugs
23
related to argument processing, startup, etc.
25
This replaces the previous test.sh which was not very portable."""
31
from subprocess import call, Popen
32
except ImportError, e:
33
sys.stderr.write("testbzr: sorry, this test suite requires modules from python2.4\n"
39
"""run one command and check the output.
41
If a single string is based, it is split into words.
42
For commands that are not simple space-separated words, please
43
pass a list instead."""
45
if isinstance(cmd, basestring):
47
logfile.write('$ %r\n' % cmd)
48
retcode = call(cmd, stdout=logfile, stderr=logfile)
50
raise Exception("test failed: %r returned %r" % (cmd, retcode))
55
logfile.write('* '+ msg + '\n')
58
TESTDIR = "bzr-test.tmp"
60
# prepare an empty scratch directory
61
if os.path.exists(TESTDIR):
62
shutil.rmtree(TESTDIR)
65
logfile = open('bzr-test.log', 'wt')
72
progress("testing introductory commands")
77
progress("all tests passed!")