[project @ 2001-04-11 18:10:16 by lewie]
[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 If you want to set compilation options globally from the commandline,
20 use `make EXTRA_HC_OPTS="-foo-option -blah', for global runstdtest options
21 use EXTRA_RUNTEST_OPTS.
22
23 -------------------------------------------------------------------------------
24                         ADDING A NEW TEST
25 -------------------------------------------------------------------------------
26
27 To add a new test copy your Haskell program into an appropriately named
28 file in the appropriate directory (for example, "typecheck/tc093.hs" for
29 the 93rd typechecker test).
30
31 If the test needs to set the compiler options to something other than
32 the default for the directory, either modify the SRC_HC_OPTS (applies
33 to all tests in that directory), or set some extra per-file compiler
34 options. For example,
35
36   tc093_HC_OPTS = -noC -ddump-tc 
37
38 -noC tells not bother generating any C (no point in doing that, since
39 we only want to test the typechecker. NOTE: Currently the driver does
40 not handle the -noC flag anymore).  -ddump-tc tells ghc to dump the
41 typechecker state.
42
43 Depending on the tests/ subdirectory, a default exit code is
44 expected from all tests therein, normally 0 (==success).
45 Per-file options to the runtests script can be set as follows
46
47   tc093_RUNTEST_OPTS = -x 1
48
49 telling the test script that the compiler is expected to fail
50 on tc093.
51
52 "touch" the file tc093.stderr.  "make tc093.o" will then run
53 the compiler and fail (because the expected output doesn't match the empty
54 tc093.stderr).  However, it is then easy to update tc093.stderr with the
55 stuff printed out during "make tc093.o". An alternative is to run
56 `make' with EXTRA_RUNTEST_OPTS=-accept-output on the new test, and the
57 runtest script will add the stderr&stdout dump files for you *in the
58 build tree*.
59