197
197
__ http://docs.python.org/lib/module-doctest.html
203
``bzrlib/tests/script.py`` allows users to write tests in a syntax very close to a shell session,
204
using a restricted and limited set of commands that should be enough to mimic
205
most of the behaviours.
207
A script is a set of commands, each command is composed of:
209
* one mandatory command line,
210
* one optional set of input lines to feed the command,
211
* one optional set of output expected lines,
212
* one optional set of error expected lines.
214
Input, output and error lines can be specified in any order.
216
Except for the expected output, all lines start with a special
217
string (based on their origin when used under a Unix shell):
219
* '$ ' for the command,
221
* nothing for output,
224
Comments can be added anywhere, they start with '#' and end with
227
The execution stops as soon as an expected output or an expected error is not
230
When no output is specified, any ouput from the command is accepted
231
and execution continue.
233
If an error occurs and no expected error is specified, the execution stops.
235
An error is defined by a returned status different from zero, not by the
236
presence of text on the error stream.
238
The matching is done on a full string comparison basis unless '...' is used, in
239
which case expected output/errors can be less precise.
243
The following will succeeds only if 'bzr add' outputs 'adding file'::
248
If you want the command to succeed for any output, just use::
252
The following will stop with an error::
256
If you want it to succeed, use::
259
2> bzr: ERROR: unknown command "not-a-command"
261
You can use ellipsis (...) to replace any piece of text you don't want to be
264
$ bzr branch not-a-branch
265
2>bzr: ERROR: Not a branch...not-a-branch/".
267
This can be used to ignore entire lines too::
273
# And here we explain that surprising fourth line
280
You can check the content of a file with cat::
285
You can also check the existence of a file with cat, the following will fail if
286
the file doesn't exist::