ali@5
|
1 |
bookloupe test framework
|
ali@5
|
2 |
========================
|
ali@0
|
3 |
|
ali@0
|
4 |
Running existing testcases
|
ali@0
|
5 |
--------------------------
|
ali@0
|
6 |
|
ali@5
|
7 |
The test harness (the program that runs a test) is called loupe-test. The
|
ali@5
|
8 |
various testcases are stored in multiple text files, typically with a .tst
|
ali@5
|
9 |
extension.
|
ali@0
|
10 |
|
ali@5
|
11 |
To run a testcase when all of bookloupe, loupe-test and the testcase file are
|
ali@0
|
12 |
in the current directory simply do something like:
|
ali@0
|
13 |
|
ali@5
|
14 |
% loupe-test missing-space.tst
|
ali@0
|
15 |
|
ali@0
|
16 |
from a command prompt. Under MS-Windows, this is called a command window and
|
ali@0
|
17 |
the prompt will normally look slightly different, eg.,
|
ali@0
|
18 |
|
ali@5
|
19 |
C:\DP> loupe-test missing-space.tst
|
ali@0
|
20 |
|
ali@0
|
21 |
To run all the tests in the current directory, do something like this:
|
ali@0
|
22 |
|
ali@5
|
23 |
% loupe-test *.tst
|
ali@0
|
24 |
|
ali@5
|
25 |
If bookloupe is not in the current directory or you want to run the testsuite
|
ali@5
|
26 |
against gutcheck (the program that bookloupe is based on), then you can set an
|
ali@5
|
27 |
environment variable (BOOKLOUPE) to point at it. For example, on MS-Windows
|
ali@5
|
28 |
you might do:
|
ali@0
|
29 |
|
ali@5
|
30 |
C:\DP> set BOOKLOUPE=C:\GUTCHECK\GUTCHECK.EXE
|
ali@5
|
31 |
C:\DP> loupe-test *.tst
|
ali@0
|
32 |
|
ali@0
|
33 |
Writing your own testcases
|
ali@0
|
34 |
--------------------------
|
ali@0
|
35 |
|
ali@0
|
36 |
Writing a new testcase is pretty painless. Most testcases follow this simple
|
ali@0
|
37 |
pattern:
|
ali@0
|
38 |
|
ali@0
|
39 |
┌──────────────────────────────────────────┐
|
ali@0
|
40 |
│**************** INPUT **************** │
|
ali@0
|
41 |
│"Look!John, over there!" │
|
ali@0
|
42 |
│**************** EXPECTED ****************│
|
ali@0
|
43 |
│ │
|
ali@0
|
44 |
│"Look!John, over there!" │
|
ali@0
|
45 |
│ Line 1 column 6 - Missing space? │
|
ali@0
|
46 |
└──────────────────────────────────────────┘
|
ali@0
|
47 |
|
ali@0
|
48 |
The sixteen asterisks in this example form what is known as the "flag". This
|
ali@0
|
49 |
flag must come before and after all tags (eg., INPUT and EXPECTED). In the
|
ali@5
|
50 |
unlikely event that you need sixteen asterisks at the start of a line of text,
|
ali@0
|
51 |
then simply choose a different flag and use it throughout the file (flags
|
ali@0
|
52 |
can be any sequence of ASCII characters except control codes and space).
|
ali@0
|
53 |
|
ali@5
|
54 |
Note that the header that bookloupe and gutcheck normally output is not
|
ali@5
|
55 |
included in the expected output. This avoids problems with not knowing
|
ali@5
|
56 |
beforehand the name of the file that bookloupe/gutcheck will be asked to
|
ali@5
|
57 |
look at (and saves typing!). bookloupe (and gutcheck) prints a blank line
|
ali@5
|
58 |
before each warning. These are not part of the header and so do need to
|
ali@5
|
59 |
be included.
|
ali@0
|
60 |
|
ali@5
|
61 |
To test that bookloupe produces no output, you still need to include
|
ali@0
|
62 |
an EXPECTED tag, just with no text following it. If there is no EXPECTED
|
ali@5
|
63 |
tag, then loupe-test will consider that no expectation exists and won't
|
ali@5
|
64 |
check the output at all.
|
ali@0
|
65 |
|
ali@0
|
66 |
There is no support yet for non-ASCII testcases, embedded linefeeds,
|
ali@5
|
67 |
passing command line options to bookloupe or for testcases which are
|
ali@0
|
68 |
expected to fail.
|