1 bookloupe test framework
2 ========================
4 Running existing testcases
5 --------------------------
7 The test harness (the program that runs a test) is called loupe-test. The
8 various testcases are stored in multiple text files, typically with a .tst
11 To run a testcase when all of bookloupe, loupe-test and the testcase file are
12 in the current directory simply do something like:
14 % loupe-test missing-space.tst
16 from a command prompt. Under MS-Windows, this is called a command window and
17 the prompt will normally look slightly different, eg.,
19 C:\DP> loupe-test missing-space.tst
21 To run all the tests in the current directory, do something like this:
25 If bookloupe is not in the current directory or you want to run the testsuite
26 against gutcheck (the program that bookloupe is based on), then you can set an
27 environment variable (BOOKLOUPE) to point at it. For example, on MS-Windows
30 C:\DP> set BOOKLOUPE=C:\GUTCHECK\GUTCHECK.EXE
31 C:\DP> loupe-test *.tst
33 Writing your own testcases
34 --------------------------
36 Writing a new testcase is pretty painless. Most testcases follow this simple
39 ┌──────────────────────────────────────────┐
40 │**************** INPUT **************** │
41 │"Look!John, over there!" │
42 │**************** EXPECTED ****************│
44 │"Look!John, over there!" │
45 │ Line 1 column 6 - Missing space? │
46 └──────────────────────────────────────────┘
48 The sixteen asterisks in this example form what is known as the "flag". This
49 flag must come before and after all tags (eg., INPUT and EXPECTED). In the
50 unlikely event that you need sixteen asterisks at the start of a line of text,
51 then simply choose a different flag and use it throughout the file (flags
52 can be any sequence of ASCII characters except control codes and space).
54 Note that the header that bookloupe and gutcheck normally output is not
55 included in the expected output. This avoids problems with not knowing
56 beforehand the name of the file that bookloupe/gutcheck will be asked to
57 look at (and saves typing!). bookloupe (and gutcheck) prints a blank line
58 before each warning. These are not part of the header and so do need to
61 To test that bookloupe produces no output, you still need to include
62 an EXPECTED tag, just with no text following it. If there is no EXPECTED
63 tag, then loupe-test will consider that no expectation exists and won't
64 check the output at all.
69 The testcase definitions (the .tst files) are always written in UTF-8
70 which is a superset of ASCII. Since gutcheck does not understand UTF-8
71 this causes a problem when it is desired to include characters that
72 are not in ASCII in a testcase. To solve this problem it is possible
73 to specify an encoding to use for the test. It is very important to
74 undertand that this specifies the encoding that loupe-test will use to
75 talk to bookloupe/gutcheck and _not_ the encoding of the .tst file
76 (which remains UTF-8). gutcheck understands Latin-1 (at least to a
77 limited extent), the canonical name for which is ISO-8859-1:
79 ┌─────────────────────────────────────────────────────────────────┐
80 │**************** ENCODING **************** │
82 │**************** INPUT **************** │
83 │"Hello," he said, "I wanted to bave a tête-à-tête with you." │
84 │**************** EXPECTED **************** │
86 │"Hello," he said, "I wanted to bave a tête-à-tête with you." │
87 │ Line 1 column 31 - Query word bave - not reporting duplicates│
88 └─────────────────────────────────────────────────────────────────┘
93 One of the tests that bookloupe/gutcheck need to do is check that all
94 lines are ended with CR NL (as required by PG) rather than the UNIX
95 standard NL. loupe-test deliberately ignores the line endings in testcase
96 definition files and always uses CR NL. Thus there is needed a means
97 to embed a linefeed (aka newline) character into the input to be sent
98 to bookloupe/gutcheck to test that it correctly identified the problem.
99 loupe-test recognises the unicode symbol for linefeed (U+240A): ␊ which
100 can be used for this purpose instead of a normal newline.
102 Passing command line options
103 ----------------------------
105 Some of bookloupe's functionality is only available using command line
106 options. loupe-test provides a means of specifying these with the
109 ┌──────────────────────────────────────────┐
110 │**************** OPTIONS **************** │
113 │**************** INPUT **************** │
114 │“He went <i>thataway!</i>” │
115 │**************** EXPECTED ****************│
116 └──────────────────────────────────────────┘
121 Under certain circumstances, bookloupe reads other input files than just
122 the ebook. These can be specified in the testcase definition file by
123 adding the name of the file to the INPUT tag:
125 ┌───────────────────────────────────────────────────────────────┐
126 │**************** OPTIONS **************** │
128 │**************** INPUT(gutcheck.typ) **************** │
130 │**************** INPUT **************** │
131 │I am the very model of a modern Major-General, │
132 │I've information vegetable, animal, and mineral, │
133 │I know the kings of England, arid I quote the fights historical│
134 │From Marathon to Waterloo, in order categorical; │
135 │I'm very well acquainted, too, with matters mathematical, │
136 │I understand equations, both the simple and quadratical, │
137 │About binomial theorem I'm teeming with a lot o' news-- │
138 │With many cheerful facts about the square of the hypotenuse. │
139 │**************** EXPECTED **************** │
141 │I know the kings of England, arid I quote the fights historical│
142 │ Line 3 column 29 - Query possible scanno arid │
143 └───────────────────────────────────────────────────────────────┘
148 There is no support yet for testcases which are expected to fail.