Build system: check $CLEANING instead of $MAKECMDGOALS
[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 ifeq "$(GhcUnregisterised)" "YES"
29 # Otherwise C backend generates many warnings about
30 # imcompatible proto casts for GCC's buitins:
31 # memcpy, printf, strlen.
32 EXTRA_HC_OPTS += -optc-fno-builtin
33 endif
34
35 # TEST_HC_OPTS is passed to every invocation of TEST_HC
36 # in nested Makefiles
37 TEST_HC_OPTS = -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-$(GhcPackageDbFlag) -rtsopts $(EXTRA_HC_OPTS)
38
39 # The warning suppression flag below is a temporary kludge. While working with
40 # tests that contain tabs, please de-tab them so this flag can be eventually
41 # removed. See
42 # http://ghc.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces
43 # for details
44 #
45 TEST_HC_OPTS += -fno-warn-tabs
46
47 RUNTEST_OPTS =
48
49 ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
50 exeext =
51 else
52 exeext = .exe
53 endif
54
55 ifneq "$(filter $(TargetOS_CPP),cygwin32 mingw32)" ""
56 dllext = .dll
57 else ifeq "$(TargetOS_CPP)" "darwin"
58 dllext = .dylib
59 else
60 dllext = .so
61 endif
62
63 RUNTEST_OPTS += -e ghc_compiler_always_flags="'$(TEST_HC_OPTS)'"
64
65 RUNTEST_OPTS += -e ghc_debugged=$(GhcDebugged)
66
67 ifeq "$(GhcWithNativeCodeGen)" "YES"
68 RUNTEST_OPTS += -e ghc_with_native_codegen=1
69 else
70 RUNTEST_OPTS += -e ghc_with_native_codegen=0
71 endif
72
73 GHC_PRIM_LIBDIR := $(subst library-dirs: ,,$(shell "$(GHC_PKG)" field ghc-prim library-dirs --simple-output))
74 HAVE_VANILLA := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.hi ]; then echo YES; else echo NO; fi)
75 HAVE_DYNAMIC := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.dyn_hi ]; then echo YES; else echo NO; fi)
76 HAVE_PROFILING := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.p_hi ]; then echo YES; else echo NO; fi)
77
78 ifeq "$(HAVE_VANILLA)" "YES"
79 RUNTEST_OPTS += -e ghc_with_vanilla=1
80 else
81 RUNTEST_OPTS += -e ghc_with_vanilla=0
82 endif
83
84 ifeq "$(HAVE_DYNAMIC)" "YES"
85 RUNTEST_OPTS += -e ghc_with_dynamic=1
86 else
87 RUNTEST_OPTS += -e ghc_with_dynamic=0
88 endif
89
90 ifeq "$(HAVE_PROFILING)" "YES"
91 RUNTEST_OPTS += -e ghc_with_profiling=1
92 else
93 RUNTEST_OPTS += -e ghc_with_profiling=0
94 endif
95
96 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
97 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
98 else
99 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
100 endif
101
102 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
103 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
104 else
105 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
106 endif
107
108 ifeq "$(GhcWithInterpreter)" "NO"
109 RUNTEST_OPTS += -e ghc_with_interpreter=0
110 else ifeq "$(GhcStage)" "1"
111 RUNTEST_OPTS += -e ghc_with_interpreter=0
112 else
113 RUNTEST_OPTS += -e ghc_with_interpreter=1
114 endif
115
116 ifeq "$(GhcUnregisterised)" "YES"
117 RUNTEST_OPTS += -e ghc_unregisterised=1
118 else
119 RUNTEST_OPTS += -e ghc_unregisterised=0
120 endif
121
122 ifeq "$(GhcDynamicByDefault)" "YES"
123 RUNTEST_OPTS += -e ghc_dynamic_by_default=True
124 CABAL_MINIMAL_BUILD = --enable-shared --disable-library-vanilla
125 else
126 RUNTEST_OPTS += -e ghc_dynamic_by_default=False
127 CABAL_MINIMAL_BUILD = --enable-library-vanilla --disable-shared
128 endif
129
130 ifeq "$(GhcDynamic)" "YES"
131 RUNTEST_OPTS += -e ghc_dynamic=True
132 CABAL_PLUGIN_BUILD = --enable-shared --disable-library-vanilla
133 else
134 RUNTEST_OPTS += -e ghc_dynamic=False
135 CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared
136 endif
137
138 ifeq "$(GhcWithSMP)" "YES"
139 RUNTEST_OPTS += -e ghc_with_smp=1
140 else
141 RUNTEST_OPTS += -e ghc_with_smp=0
142 endif
143
144 ifeq "$(LLC)" ""
145 RUNTEST_OPTS += -e ghc_with_llvm=0
146 else ifneq "$(LLC)" "llc"
147 # If we have a real detected value for LLVM, then it really ought to work
148 RUNTEST_OPTS += -e ghc_with_llvm=1
149 else ifneq "$(shell $(SHELL) -c 'llc --version | grep version' 2> /dev/null)" ""
150 RUNTEST_OPTS += -e ghc_with_llvm=1
151 else
152 RUNTEST_OPTS += -e ghc_with_llvm=0
153 endif
154
155 ifeq "$(WINDOWS)" "YES"
156 RUNTEST_OPTS += -e windows=True
157 else
158 RUNTEST_OPTS += -e windows=False
159 endif
160
161 ifeq "$(DARWIN)" "YES"
162 RUNTEST_OPTS += -e darwin=True
163 else
164 RUNTEST_OPTS += -e darwin=False
165 endif
166
167 ifeq "$(IN_TREE_COMPILER)" "YES"
168 RUNTEST_OPTS += -e in_tree_compiler=True
169 else
170 RUNTEST_OPTS += -e in_tree_compiler=False
171 endif
172
173 ifneq "$(THREADS)" ""
174 RUNTEST_OPTS += --threads=$(THREADS)
175 endif
176
177 ifneq "$(VERBOSE)" ""
178 RUNTEST_OPTS += --verbose=$(VERBOSE)
179 endif
180
181 ifeq "$(SKIP_PERF_TESTS)" "YES"
182 RUNTEST_OPTS += --skip-perf-tests
183 endif
184
185 ifneq "$(CLEAN_ONLY)" ""
186 RUNTEST_OPTS += -e clean_only=True
187 else
188 RUNTEST_OPTS += -e clean_only=False
189 endif
190
191 ifneq "$(CHECK_FILES_WRITTEN)" ""
192 RUNTEST_OPTS += --check-files-written
193 endif
194
195 RUNTEST_OPTS += \
196 --rootdir=. \
197 --configfile=$(CONFIG) \
198 -e 'config.confdir="$(CONFIGDIR)"' \
199 -e 'config.platform="$(TARGETPLATFORM)"' \
200 -e 'config.os="$(TargetOS_CPP)"' \
201 -e 'config.arch="$(TargetARCH_CPP)"' \
202 -e 'config.wordsize="$(WORDSIZE)"' \
203 -e 'default_testopts.cleanup="$(CLEANUP)"' \
204 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
205 -e 'config.exeext="$(exeext)"' \
206 -e 'config.top="$(TOP_ABS)"'
207
208 # Wrap non-empty program paths in quotes, because they may contain spaces. Do
209 # it here, so we don't have to (and don't forget to do it) in the .T test
210 # scripts (search for '{compiler}' or '{hpc}'). This may or may not be a good
211 # idea.
212 # Use `--config` instead of `-e`, because `-e` (which calls Python's `eval`
213 # function) would require another pair of (escaped) quotes, which interfers
214 # with MinGW's magic path handling (see #10449, and
215 # http://www.mingw.org/wiki/Posix_path_conversion).
216 quote_path = $(if $1,"$1")
217 RUNTEST_OPTS += \
218 --config 'compiler=$(call quote_path,$(TEST_HC))' \
219 --config 'ghc_pkg=$(call quote_path,$(GHC_PKG))' \
220 --config 'haddock=$(call quote_path,$(HADDOCK))' \
221 --config 'hp2ps=$(call quote_path,$(HP2PS_ABS))' \
222 --config 'hpc=$(call quote_path,$(HPC))' \
223 --config 'gs=$(call quote_path,$(GS))' \
224 --config 'timeout_prog=$(call quote_path,$(TIMEOUT_PROGRAM))'
225
226 ifneq "$(OUTPUT_SUMMARY)" ""
227 RUNTEST_OPTS += \
228 --output-summary "$(OUTPUT_SUMMARY)"
229 endif
230
231 RUNTEST_OPTS += \
232 $(EXTRA_RUNTEST_OPTS)
233
234 ifeq "$(list_broken)" "YES"
235 set_list_broken = -e config.list_broken=True
236 else
237 set_list_broken =
238 endif
239
240 ifeq "$(fast)" "YES"
241 setfast = -e config.fast=1
242 else
243 setfast =
244 endif
245
246 ifeq "$(accept)" "YES"
247 setaccept = -e config.accept=1
248 else
249 setaccept =
250 endif
251
252 TESTS =
253 TEST =
254 WAY =
255
256 .PHONY: all boot test verbose accept fast list_broken
257
258 all: test
259
260 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
261
262 boot: $(TIMEOUT_PROGRAM)
263
264 $(TIMEOUT_PROGRAM) :
265 @echo "Looks like you don't have timeout, building it first..."
266 $(MAKE) -C $(TOP)/timeout all
267
268 test: $(TIMEOUT_PROGRAM)
269 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
270 $(patsubst %, --only=%, $(TEST)) \
271 $(patsubst %, --only=%, $(TESTS)) \
272 $(patsubst %, --way=%, $(WAY)) \
273 $(patsubst %, --skipway=%, $(SKIPWAY)) \
274 $(set_list_broken) \
275 $(setfast) \
276 $(setaccept)
277
278 verbose: test
279
280 accept:
281 $(MAKE) accept=YES
282
283 fast:
284 $(MAKE) fast=YES
285
286 list_broken:
287 $(MAKE) list_broken=YES
288