[project @ 1997-09-03 23:37:24 by sof]
[ghc-hetmet.git] / ghc / tests / README
1 -------------------------------------------------------------------------------
2                         GHC COMPILER TESTS
3 -------------------------------------------------------------------------------
4
5 This directory contains the regression tests for the compiler and the
6 prelude libraries.  Regression tests meaning "correctness", NoFib
7 deals with "performance". Note that regression tests for other parts
8 of the ghc system (such as the driver, runtime system, system libs)
9 belong elsewhere.
10
11 Each test takes the form of a single program (for example, reader001.hs)
12 and files which specify ghc's expected error output (reader001.stderr).
13
14 "make reader001.runtest" will compile reader001.hs using ghc and compare
15 the resulting output with that specified in the file reader001.stderr.
16
17 "make all" run all tests.
18
19 -------------------------------------------------------------------------------
20                         ADDING A NEW TEST
21 -------------------------------------------------------------------------------
22
23 To add a new test copy your Haskell program into an appropriately named
24 file in the appropriate directory (for example, "typecheck/tc093.hs" for
25 the 93rd typechecker test).
26
27 If the test needs to set the compiler options to something other than
28 the default for the directory, either modify the SRC_HC_OPTS (applies
29 to all tests in that directory), or set some extra per-file compiler
30 options. For example,
31
32   tc093_HC_OPTS = -noC -ddump-tc 
33
34 -noC tells not bother generating any C (not point in doing that, since we
35 only want to test the typechecker).  -ddump-tc tells ghc to dump the
36 typechecker state. 
37
38 Depending on the tests/ subdirectory, a default exit code is
39 expected from all tests therein, normally 0 (==success).
40 Per-file options to the runtests script can be set as follows
41
42   tc093_RUNTEST_OPTS = -x 1
43
44 telling the test script that the compiler is expected to fail
45 on tc093.
46
47 "touch" the file tc093.stderr.  "make tc093.o" will then run
48 the compiler and fail (because the expected output doesn't match the empty
49 tc093.stderr).  However, it is then easy to update tc093.stderr with the
50 stuff printed out during "make tc093.o". An alternative is to run
51 `make' with EXTRA_RUNTEST_OPTS=-accept-output on the new test, and the
52 runtest script will add the stderr&stdout dump files for you *in the
53 build tree*.
54