Test driver: Implement different verbosities
[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-$(GhcPackageDbFlag) -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 ifneq "$(filter $(TargetOS_CPP),cygwin32 mingw32)" ""
41 dllext = .dll
42 else ifeq "$(TargetOS_CPP)" "darwin"
43 dllext = .dylib
44 else
45 dllext = .so
46 endif
47
48 RUNTEST_OPTS += -e ghc_compiler_always_flags="'$(TEST_HC_OPTS)'"
49
50 RUNTEST_OPTS += -e ghc_debugged=$(GhcDebugged)
51
52 ifeq "$(GhcWithNativeCodeGen)" "YES"
53 RUNTEST_OPTS += -e ghc_with_native_codegen=1
54 else
55 RUNTEST_OPTS += -e ghc_with_native_codegen=0
56 endif
57
58 GHC_PRIM_LIBDIR := $(shell "$(GHC_PKG)" field ghc-prim library-dirs --simple-output)
59 HAVE_VANILLA := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.hi ]; then echo YES; else echo NO; fi)
60 HAVE_DYNAMIC := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.dyn_hi ]; then echo YES; else echo NO; fi)
61 HAVE_PROFILING := $(shell if [ -f $(subst \,/,$(GHC_PRIM_LIBDIR))/GHC/PrimopWrappers.p_hi ]; then echo YES; else echo NO; fi)
62
63 ifeq "$(HAVE_VANILLA)" "YES"
64 RUNTEST_OPTS += -e ghc_with_vanilla=1
65 else
66 RUNTEST_OPTS += -e ghc_with_vanilla=0
67 endif
68
69 ifeq "$(HAVE_DYNAMIC)" "YES"
70 RUNTEST_OPTS += -e ghc_with_dynamic=1
71 else
72 RUNTEST_OPTS += -e ghc_with_dynamic=0
73 endif
74
75 ifeq "$(HAVE_PROFILING)" "YES"
76 RUNTEST_OPTS += -e ghc_with_profiling=1
77 else
78 RUNTEST_OPTS += -e ghc_with_profiling=0
79 endif
80
81 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
82 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
83 else
84 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
85 endif
86
87 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
88 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
89 else
90 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
91 endif
92
93 ifeq "$(GhcWithInterpreter)" "NO"
94 RUNTEST_OPTS += -e ghc_with_interpreter=0
95 else ifeq "$(GhcStage)" "1"
96 RUNTEST_OPTS += -e ghc_with_interpreter=0
97 else
98 RUNTEST_OPTS += -e ghc_with_interpreter=1
99 endif
100
101 ifeq "$(GhcUnregisterised)" "YES"
102 RUNTEST_OPTS += -e ghc_unregisterised=1
103 else
104 RUNTEST_OPTS += -e ghc_unregisterised=0
105 endif
106
107 ifeq "$(GhcDynamicByDefault)" "YES"
108 RUNTEST_OPTS += -e ghc_dynamic_by_default=True
109 CABAL_MINIMAL_BUILD = --enable-shared --disable-library-vanilla
110 else
111 RUNTEST_OPTS += -e ghc_dynamic_by_default=False
112 CABAL_MINIMAL_BUILD = --enable-library-vanilla --disable-shared
113 endif
114
115 ifeq "$(GhcDynamic)" "YES"
116 RUNTEST_OPTS += -e ghc_dynamic=True
117 CABAL_PLUGIN_BUILD = --enable-shared --disable-library-vanilla
118 else
119 RUNTEST_OPTS += -e ghc_dynamic=False
120 CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared
121 endif
122
123 ifeq "$(GhcWithSMP)" "YES"
124 RUNTEST_OPTS += -e ghc_with_smp=1
125 else
126 RUNTEST_OPTS += -e ghc_with_smp=0
127 endif
128
129 ifeq "$(LLC)" ""
130 RUNTEST_OPTS += -e ghc_with_llvm=0
131 else ifneq "$(LLC)" "llc"
132 # If we have a real detected value for LLVM, then it really ought to work
133 RUNTEST_OPTS += -e ghc_with_llvm=1
134 else ifneq "$(shell $(SHELL) -c 'llc --version | grep version' 2> /dev/null)" ""
135 RUNTEST_OPTS += -e ghc_with_llvm=1
136 else
137 RUNTEST_OPTS += -e ghc_with_llvm=0
138 endif
139
140 ifeq "$(WINDOWS)" "YES"
141 RUNTEST_OPTS += -e windows=True
142 else
143 RUNTEST_OPTS += -e windows=False
144 endif
145
146 ifeq "$(DARWIN)" "YES"
147 RUNTEST_OPTS += -e darwin=True
148 else
149 RUNTEST_OPTS += -e darwin=False
150 endif
151
152 ifeq "$(IN_TREE_COMPILER)" "YES"
153 RUNTEST_OPTS += -e in_tree_compiler=True
154 else
155 RUNTEST_OPTS += -e in_tree_compiler=False
156 endif
157
158 ifneq "$(THREADS)" ""
159 RUNTEST_OPTS += --threads=$(THREADS)
160 endif
161
162 ifneq "$(VERBOSE)" ""
163 RUNTEST_OPTS += --verbose=$(VERBOSE)
164 endif
165
166 ifneq "$(CLEAN_ONLY)" ""
167 RUNTEST_OPTS += -e clean_only=True
168 else
169 RUNTEST_OPTS += -e clean_only=False
170 endif
171
172 ifneq "$(CHECK_FILES_WRITTEN)" ""
173 RUNTEST_OPTS += --check-files-written
174 endif
175
176 RUNTEST_OPTS += \
177 --rootdir=. \
178 --config=$(CONFIG) \
179 -e 'config.confdir="$(CONFIGDIR)"' \
180 -e 'config.compiler="$(TEST_HC)"' \
181 -e 'config.ghc_pkg="$(GHC_PKG)"' \
182 -e 'config.hp2ps="$(HP2PS_ABS)"' \
183 -e 'config.hpc="$(HPC)"' \
184 -e 'config.gs="$(GS)"' \
185 -e 'config.platform="$(TARGETPLATFORM)"' \
186 -e 'config.os="$(TargetOS_CPP)"' \
187 -e 'config.arch="$(TargetARCH_CPP)"' \
188 -e 'config.wordsize="$(WORDSIZE)"' \
189 -e 'default_testopts.cleanup="$(CLEANUP)"' \
190 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
191 -e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
192 -e 'config.exeext="$(exeext)"' \
193 -e 'config.top="$(TOP_ABS)"'
194
195 ifneq "$(OUTPUT_SUMMARY)" ""
196 RUNTEST_OPTS += \
197 --output-summary "$(OUTPUT_SUMMARY)"
198 endif
199
200 RUNTEST_OPTS += \
201 $(EXTRA_RUNTEST_OPTS)
202
203 ifeq "$(list_broken)" "YES"
204 set_list_broken = -e config.list_broken=True
205 else
206 set_list_broken =
207 endif
208
209 ifeq "$(fast)" "YES"
210 setfast = -e config.fast=1
211 else
212 setfast =
213 endif
214
215 ifeq "$(accept)" "YES"
216 setaccept = -e config.accept=1
217 else
218 setaccept =
219 endif
220
221 TESTS =
222 TEST =
223 WAY =
224
225 .PHONY: all boot test verbose accept fast
226
227 all: test
228
229 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
230
231 boot: $(TIMEOUT_PROGRAM)
232
233 $(TIMEOUT_PROGRAM) :
234 @echo "Looks like you don't have timeout, building it first..."
235 $(MAKE) -C $(TOP)/timeout all
236
237 test: $(TIMEOUT_PROGRAM)
238 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
239 $(patsubst %, --only=%, $(TEST)) \
240 $(patsubst %, --only=%, $(TESTS)) \
241 $(patsubst %, --way=%, $(WAY)) \
242 $(patsubst %, --skipway=%, $(SKIPWAY)) \
243 $(set_list_broken) \
244 $(setfast) \
245 $(setaccept)
246
247 verbose: test
248
249 accept:
250 $(MAKE) accept=YES
251
252 fast:
253 $(MAKE) fast=YES
254
255 list_broken:
256 $(MAKE) list_broken=YES
257