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