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@10
|
66 |
Non-ASCII testcases
|
ali@10
|
67 |
-------------------
|
ali@10
|
68 |
|
ali@10
|
69 |
The testcase definitions (the .tst files) are always written in UTF-8
|
ali@10
|
70 |
which is a superset of ASCII. Since gutcheck does not understand UTF-8
|
ali@10
|
71 |
this causes a problem when it is desired to include characters that
|
ali@10
|
72 |
are not in ASCII in a testcase. To solve this problem it is possible
|
ali@10
|
73 |
to specify an encoding to use for the test. It is very important to
|
ali@10
|
74 |
undertand that this specifies the encoding that loupe-test will use to
|
ali@10
|
75 |
talk to bookloupe/gutcheck and _not_ the encoding of the .tst file
|
ali@10
|
76 |
(which remains UTF-8). gutcheck understands Latin-1 (at least to a
|
ali@10
|
77 |
limited extent), the canonical name for which is ISO-8859-1:
|
ali@10
|
78 |
|
ali@10
|
79 |
┌─────────────────────────────────────────────────────────────────┐
|
ali@10
|
80 |
│**************** ENCODING **************** │
|
ali@10
|
81 |
│ISO-8859-1 │
|
ali@10
|
82 |
│**************** INPUT **************** │
|
ali@10
|
83 |
│"Hello," he said, "I wanted to bave a tête-à-tête with you." │
|
ali@10
|
84 |
│**************** EXPECTED **************** │
|
ali@10
|
85 |
│ │
|
ali@10
|
86 |
│"Hello," he said, "I wanted to bave a tête-à-tête with you." │
|
ali@10
|
87 |
│ Line 1 column 31 - Query word bave - not reporting duplicates│
|
ali@10
|
88 |
└─────────────────────────────────────────────────────────────────┘
|
ali@10
|
89 |
|
ali@10
|
90 |
Embedded linefeeds
|
ali@10
|
91 |
------------------
|
ali@10
|
92 |
|
ali@10
|
93 |
One of the tests that bookloupe/gutcheck need to do is check that all
|
ali@10
|
94 |
lines are ended with CR NL (as required by PG) rather than the UNIX
|
ali@10
|
95 |
standard NL. loupe-test deliberately ignores the line endings in testcase
|
ali@10
|
96 |
definition files and always uses CR NL. Thus there is needed a means
|
ali@10
|
97 |
to embed a linefeed (aka newline) character into the input to be sent
|
ali@10
|
98 |
to bookloupe/gutcheck to test that it correctly identified the problem.
|
ali@10
|
99 |
loupe-test recognises the unicode symbol for linefeed (U+240A): ␊ which
|
ali@10
|
100 |
can be used for this purpose instead of a normal newline.
|
ali@10
|
101 |
|
ali@10
|
102 |
Passing command line options
|
ali@10
|
103 |
----------------------------
|
ali@10
|
104 |
|
ali@10
|
105 |
Some of bookloupe's functionality is only available using command line
|
ali@10
|
106 |
options. loupe-test provides a means of specifying these with the
|
ali@10
|
107 |
OPTIONS tag:
|
ali@10
|
108 |
|
ali@10
|
109 |
┌──────────────────────────────────────────┐
|
ali@10
|
110 |
│**************** OPTIONS **************** │
|
ali@10
|
111 |
│-m │
|
ali@10
|
112 |
│-d │
|
ali@10
|
113 |
│**************** INPUT **************** │
|
ali@10
|
114 |
│“He went <i>thataway!</i>” │
|
ali@10
|
115 |
│**************** EXPECTED ****************│
|
ali@10
|
116 |
└──────────────────────────────────────────┘
|
ali@10
|
117 |
|
ali@10
|
118 |
Extra input files
|
ali@10
|
119 |
-----------------
|
ali@10
|
120 |
|
ali@10
|
121 |
Under certain circumstances, bookloupe reads other input files than just
|
ali@10
|
122 |
the ebook. These can be specified in the testcase definition file by
|
ali@10
|
123 |
adding the name of the file to the INPUT tag:
|
ali@10
|
124 |
|
ali@10
|
125 |
┌───────────────────────────────────────────────────────────────┐
|
ali@10
|
126 |
│**************** OPTIONS **************** │
|
ali@10
|
127 |
│-u │
|
ali@10
|
128 |
│**************** INPUT(gutcheck.typ) **************** │
|
ali@10
|
129 |
│arid │
|
ali@10
|
130 |
│**************** INPUT **************** │
|
ali@10
|
131 |
│I am the very model of a modern Major-General, │
|
ali@10
|
132 |
│I've information vegetable, animal, and mineral, │
|
ali@10
|
133 |
│I know the kings of England, arid I quote the fights historical│
|
ali@10
|
134 |
│From Marathon to Waterloo, in order categorical; │
|
ali@10
|
135 |
│I'm very well acquainted, too, with matters mathematical, │
|
ali@10
|
136 |
│I understand equations, both the simple and quadratical, │
|
ali@10
|
137 |
│About binomial theorem I'm teeming with a lot o' news-- │
|
ali@10
|
138 |
│With many cheerful facts about the square of the hypotenuse. │
|
ali@10
|
139 |
│**************** EXPECTED **************** │
|
ali@10
|
140 |
│ │
|
ali@10
|
141 |
│I know the kings of England, arid I quote the fights historical│
|
ali@10
|
142 |
│ Line 3 column 29 - Query possible scanno arid │
|
ali@10
|
143 |
└───────────────────────────────────────────────────────────────┘
|
ali@10
|
144 |
|
ali@10
|
145 |
Caveats
|
ali@10
|
146 |
-------
|
ali@10
|
147 |
|
ali@10
|
148 |
There is no support yet for testcases which are expected to fail.
|