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