Merge branch 'master' of darcs.haskell.org:/srv/darcs//testsuite
[ghc.git] / testsuite / mk / test.mk
1 # -----------------------------------------------------------------------------
2 # Examples of use:
3 #
4 # make -- run all the tests in the current directory
5 # make verbose -- as make test, but up the verbosity
6 # make accept -- run the tests, accepting the current output
7 #
8 # The following variables may be set on the make command line:
9 #
10 # TEST -- specific test to run
11 # TESTS -- specific tests to run (same as $TEST really)
12 # EXTRA_HC_OPTS -- extra flags to send to the Haskell compiler
13 # EXTRA_RUNTEST_OPTS -- extra flags to give the test driver
14 # CONFIG -- use a different configuration file
15 # COMPILER -- select a configuration file from config/
16 # THREADS -- run n tests at once
17 #
18 # -----------------------------------------------------------------------------
19
20 # export the value of $MAKE for invocation in tests/driver/
21 export MAKE
22
23 RUNTESTS = $(TOP)/driver/runtests.py
24 COMPILER = ghc
25 CONFIGDIR = $(TOP)/config
26 CONFIG = $(CONFIGDIR)/$(COMPILER)
27
28 # TEST_HC_OPTS is passed to every invocation of TEST_HC
29 # in nested Makefiles
30 TEST_HC_OPTS = -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts $(EXTRA_HC_OPTS)
31
32 RUNTEST_OPTS =
33
34 ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
35 exeext =
36 else
37 exeext = .exe
38 endif
39
40 RUNTEST_OPTS += -e ghc_compiler_always_flags="'$(TEST_HC_OPTS)'"
41
42 ifeq "$(GhcWithNativeCodeGen)" "YES"
43 RUNTEST_OPTS += -e ghc_with_native_codegen=1
44 else
45 RUNTEST_OPTS += -e ghc_with_native_codegen=0
46 endif
47
48 HASKELL98_LIBDIR := $(shell "$(GHC_PKG)" field haskell98 library-dirs | sed 's/^[^:]*: *//')
49 HAVE_PROFILING := $(shell if [ -f $(subst \,/,$(HASKELL98_LIBDIR))/libHShaskell98-*_p.a ]; then echo YES; else echo NO; fi)
50
51 ifeq "$(HAVE_PROFILING)" "YES"
52 RUNTEST_OPTS += -e ghc_with_profiling=1
53 else
54 RUNTEST_OPTS += -e ghc_with_profiling=0
55 endif
56
57 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
58 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
59 else
60 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
61 endif
62
63 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
64 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
65 else
66 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
67 endif
68
69 ifeq "$(GhcWithInterpreter)" "NO"
70 RUNTEST_OPTS += -e ghc_with_interpreter=0
71 else ifeq "$(GhcStage)" "1"
72 RUNTEST_OPTS += -e ghc_with_interpreter=0
73 else
74 RUNTEST_OPTS += -e ghc_with_interpreter=1
75 endif
76
77 ifeq "$(GhcUnregisterised)" "YES"
78 RUNTEST_OPTS += -e ghc_unregisterised=1
79 else
80 RUNTEST_OPTS += -e ghc_unregisterised=0
81 endif
82
83 ifeq "$(GhcWithSMP)" "YES"
84 RUNTEST_OPTS += -e ghc_with_smp=1
85 else
86 RUNTEST_OPTS += -e ghc_with_smp=0
87 endif
88
89 ifneq "$(shell $(SHELL) -c 'llc --version | grep version' 2> /dev/null)" ""
90 RUNTEST_OPTS += -e ghc_with_llvm=1
91 else
92 RUNTEST_OPTS += -e ghc_with_llvm=0
93 endif
94
95 ifeq "$(WINDOWS)" "YES"
96 RUNTEST_OPTS += -e windows=True
97 else
98 RUNTEST_OPTS += -e windows=False
99 endif
100
101 ifeq "$(DARWIN)" "YES"
102 RUNTEST_OPTS += -e darwin=True
103 else
104 RUNTEST_OPTS += -e darwin=False
105 endif
106
107 ifeq "$(IN_TREE_COMPILER)" "YES"
108 RUNTEST_OPTS += -e in_tree_compiler=True
109 else
110 RUNTEST_OPTS += -e in_tree_compiler=False
111 endif
112
113 ifneq "$(THREADS)" ""
114 RUNTEST_OPTS += --threads=$(THREADS)
115 endif
116
117 ifneq "$(CLEAN_ONLY)" ""
118 RUNTEST_OPTS += -e clean_only=True
119 else
120 RUNTEST_OPTS += -e clean_only=False
121 endif
122
123 ifneq "$(CHECK_FILES_WRITTEN)" ""
124 RUNTEST_OPTS += --check-files-written
125 endif
126
127 RUNTEST_OPTS += \
128 --rootdir=. \
129 --config=$(CONFIG) \
130 -e 'config.confdir="$(CONFIGDIR)"' \
131 -e 'config.compiler="$(TEST_HC)"' \
132 -e 'config.compiler_always_flags.append("$(EXTRA_HC_OPTS)")' \
133 -e 'config.ghc_pkg="$(GHC_PKG)"' \
134 -e 'config.hp2ps="$(HP2PS_ABS)"' \
135 -e 'config.hpc="$(HPC)"' \
136 -e 'config.gs="$(GS)"' \
137 -e 'config.platform="$(TARGETPLATFORM)"' \
138 -e 'config.os="$(TargetOS_CPP)"' \
139 -e 'config.arch="$(TargetARCH_CPP)"' \
140 -e 'config.wordsize="$(WORDSIZE)"' \
141 -e 'default_testopts.cleanup="$(CLEANUP)"' \
142 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
143 -e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
144 -e 'config.exeext="$(exeext)"' \
145 -e 'config.top="$(TOP_ABS)"'
146
147 ifneq "$(OUTPUT_SUMMARY)" ""
148 RUNTEST_OPTS += \
149 --output-summary "$(OUTPUT_SUMMARY)"
150 endif
151
152 RUNTEST_OPTS += \
153 $(EXTRA_RUNTEST_OPTS)
154
155 ifeq "$(fast)" "YES"
156 setfast = -e config.fast=1
157 else
158 setfast =
159 endif
160
161 ifeq "$(accept)" "YES"
162 setaccept = -e config.accept=1
163 else
164 setaccept =
165 endif
166
167 TESTS =
168 TEST =
169 WAY =
170
171 .PHONY: all boot test verbose accept fast
172
173 all: test
174
175 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
176
177 boot: $(TIMEOUT_PROGRAM)
178
179 $(TIMEOUT_PROGRAM) :
180 @echo "Looks like you don't have timeout, building it first..."
181 $(MAKE) -C $(TOP)/timeout all
182
183 test: $(TIMEOUT_PROGRAM)
184 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
185 $(patsubst %, --only=%, $(TEST)) \
186 $(patsubst %, --only=%, $(TESTS)) \
187 $(patsubst %, --way=%, $(WAY)) \
188 $(patsubst %, --skipway=%, $(SKIPWAY)) \
189 $(setfast) \
190 $(setaccept)
191
192 verbose: test
193
194 accept:
195 $(MAKE) accept=YES
196
197 fast:
198 $(MAKE) fast=YES
199