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