[project @ 1996-11-26 12:46:28 by dnt]
[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 runtests" 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 Edit the Makefile in that directory to add your test.  Most directories
26 have some flags which are set for every test (RUNSTDTEST_OPTS), but you can
27 also set some extra per-file runtest flags (to control the output of ghc,
28 for instance).  Just set ttc093_flags to the flags you want.
29
30 For example,
31
32   tc093_flags = -noC -ddump-tc -x1
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 typechcker state, while -x1 tells runtest that the expected exit code is 1,
37 not 0 (the default).
38
39 "touch" the file tc093.stderr.  "make tc093.runtest" will then build
40 tc093.runtest and fail (because the expected output doesn't match the empty
41 tc093.stderr).  However, it is then easy to update tc093.stderr with the
42 stuff printed out during "make tc093.runtest".