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