~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testbzr

  • Committer: Martin Pool
  • Date: 2005-04-28 08:50:42 UTC
  • Revision ID: mbp@sourcefrog.net-20050428085042-4d73f3b8d96c2598
- better reports from testbzr when it fails

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
This replaces the previous test.sh which was not very portable."""
26
26
 
27
 
import sys, os
 
27
import sys, os, traceback
28
28
 
29
29
try:
30
30
    import shutil
35
35
    sys.exit(1)
36
36
 
37
37
 
 
38
class CommandFailed(Exception):
 
39
    pass
 
40
 
 
41
 
38
42
def runcmd(cmd):
39
43
    """run one command and check the output.
40
44
 
47
51
    logfile.write('$ %r\n' % cmd)
48
52
    retcode = call(cmd, stdout=logfile, stderr=logfile)
49
53
    if retcode != 0:
50
 
        raise Exception("test failed: %r returned %r" % (cmd, retcode))
 
54
        raise CommandFailed("test failed: %r returned %r" % (cmd, retcode))
51
55
 
52
56
 
53
57
def progress(msg):
65
69
logfile = open('bzr-test.log', 'wt')
66
70
 
67
71
 
68
 
os.mkdir(TESTDIR)
69
 
os.chdir(TESTDIR)
70
 
 
71
 
 
72
 
progress("testing introductory commands")
73
 
runcmd("bzr version")
74
 
runcmd("bzr help")
75
 
runcmd("bzr --help")
76
 
 
77
 
progress("all tests passed!")
 
72
try: 
 
73
    os.mkdir(TESTDIR)
 
74
    os.chdir(TESTDIR)
 
75
 
 
76
 
 
77
    progress("testing introductory commands")
 
78
    runcmd("bzr version")
 
79
    runcmd("bzr help")
 
80
    runcmd("bzr --helpx")
 
81
 
 
82
    progress("all tests passed!")
 
83
except Exception, e:
 
84
    sys.stderr.write('*' * 50 + '\n'
 
85
                     + 'testbzr: tests failed\n'
 
86
                     + 'see bzr-test.log for more information\n'
 
87
                     + '*' * 50 + '\n')
 
88
    logfile.write('tests failed!\n')
 
89
    traceback.print_exc(None, logfile)
 
90
    sys.exit(1)