~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testbzr

  • Committer: Martin Pool
  • Date: 2005-04-28 09:15:31 UTC
  • Revision ID: mbp@sourcefrog.net-20050428091531-6afc92ea0e82bb94
- more tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
 
42
42
def runcmd(cmd, retcode=0):
43
 
    """run one command and check the output.
 
43
    """Run one command and check the return code.
44
44
 
45
45
    If a single string is based, it is split into words.
46
46
    For commands that are not simple space-separated words, please
69
69
    os.chdir(dirname)
70
70
 
71
71
 
 
72
 
72
73
def log_linenumber():
73
74
    """Log the stack frame location two things up."""
74
75
    stack = traceback.extract_stack()[-3]
85
86
logfile = open('testbzr.log', 'wt', buffering=1)
86
87
 
87
88
 
88
 
try: 
89
 
    os.mkdir(TESTDIR)
 
89
try:
 
90
    runcmd(['mkdir', TESTDIR])
90
91
    cd(TESTDIR)
91
92
 
92
 
    progress("testing introductory commands")
 
93
    progress("introductory commands")
93
94
    runcmd("bzr version")
94
95
    runcmd("bzr help")
95
96
    runcmd("bzr --help")
96
97
 
97
 
    progress("testing user identity")
 
98
    progress("user identity")
98
99
    # this should always identify something, if only "john@localhost"
99
100
    runcmd("bzr whoami")
100
101
    runcmd("bzr whoami --email")
101
102
 
102
 
    progress("testing invalid commands")
 
103
    progress("invalid commands")
103
104
    runcmd("bzr pants", retcode=1)
104
105
    runcmd("bzr --pants off", retcode=1)
105
106
 
 
107
    progress("basic branch creation")
 
108
    runcmd(['mkdir', 'branch1'])
 
109
    cd('branch1')
 
110
    runcmd('bzr init')
 
111
    
 
112
    f = file('test.txt', 'wt')
 
113
    f.write('hello world!\n')
 
114
    f.close()
 
115
 
 
116
    
 
117
 
 
118
    cd('..')
 
119
 
106
120
    progress("all tests passed!")
107
121
except Exception, e:
108
122
    sys.stderr.write('*' * 50 + '\n'
112
126
    logfile.write('tests failed!\n')
113
127
    traceback.print_exc(None, logfile)
114
128
    sys.exit(1)
 
129