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