Don't clean tests that we aren't running
[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 = -dno-debug-output $(EXTRA_HC_OPTS)
31
32 RUNTEST_OPTS =
33
34 $(eval $(call get-ghc-rts-field,WORDSIZE,Word size))
35 $(eval $(call get-ghc-rts-field,TARGETPLATFORM,Target platform))
36 $(eval $(call get-ghc-rts-field,TargetOS_CPP,Target OS))
37 $(eval $(call get-ghc-rts-field,TargetARCH_CPP,Target architecture))
38 ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
39 exeext =
40 else
41 exeext = .exe
42 endif
43
44 $(eval $(call get-ghc-feature-bool,GhcWithNativeCodeGen,Have native code generator))
45 ifeq "$(GhcWithNativeCodeGen)" "YES"
46 RUNTEST_OPTS += -e ghc_with_native_codegen=1
47 else
48 RUNTEST_OPTS += -e ghc_with_native_codegen=0
49 endif
50
51 HASKELL98_LIBDIR := $(shell "$(GHC_PKG)" field haskell98 library-dirs | sed 's/^[^:]*: *//')
52 HAVE_PROFILING := $(shell if [ -f $(HASKELL98_LIBDIR)/libHShaskell98-*_p.a ]; then echo YES; else echo NO; fi)
53
54 ifeq "$(HAVE_PROFILING)" "YES"
55 RUNTEST_OPTS += -e ghc_with_profiling=1
56 else
57 RUNTEST_OPTS += -e ghc_with_profiling=0
58 endif
59
60 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
61 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
62 else
63 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
64 endif
65
66 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
67 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
68 else
69 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
70 endif
71
72 $(eval $(call get-ghc-field,GhcStage,Stage))
73 $(eval $(call get-ghc-feature-bool,GhcWithInterpreter,Have interpreter))
74 ifeq "$(GhcWithInterpreter)" "NO"
75 RUNTEST_OPTS += -e ghc_with_interpreter=0
76 else ifeq "$(GhcStage)" "1"
77 RUNTEST_OPTS += -e ghc_with_interpreter=0
78 else
79 RUNTEST_OPTS += -e ghc_with_interpreter=1
80 endif
81
82 $(eval $(call get-ghc-feature-bool,GhcUnregisterised,Unregisterised))
83 ifeq "$(GhcUnregisterised)" "YES"
84 RUNTEST_OPTS += -e ghc_unregisterised=1
85 else
86 RUNTEST_OPTS += -e ghc_unregisterised=0
87 endif
88
89 $(eval $(call get-ghc-feature-bool,GhcWithSMP,Support SMP))
90 ifeq "$(GhcWithSMP)" "YES"
91 RUNTEST_OPTS += -e ghc_with_smp=1
92 else
93 RUNTEST_OPTS += -e ghc_with_smp=0
94 endif
95
96 ifneq "$(shell $(SHELL) -c 'llvmc --version | grep version' 2> /dev/null)" ""
97 RUNTEST_OPTS += -e ghc_with_llvm=1
98 else
99 RUNTEST_OPTS += -e ghc_with_llvm=0
100 endif
101
102 ifeq "$(WINDOWS)" "YES"
103 RUNTEST_OPTS += -e windows=True
104 else
105 RUNTEST_OPTS += -e windows=False
106 endif
107
108 ifeq "$(DARWIN)" "YES"
109 RUNTEST_OPTS += -e darwin=True
110 else
111 RUNTEST_OPTS += -e darwin=False
112 endif
113
114 ifeq "$(IN_TREE_COMPILER)" "YES"
115 RUNTEST_OPTS += -e in_tree_compiler=True
116 else
117 RUNTEST_OPTS += -e in_tree_compiler=False
118 endif
119
120 ifneq "$(THREADS)" ""
121 RUNTEST_OPTS += --threads=$(THREADS)
122 endif
123
124 ifneq "$(CLEAN_ONLY)" ""
125 RUNTEST_OPTS += -e clean_only=True
126 else
127 RUNTEST_OPTS += -e clean_only=False
128 endif
129
130 ifneq "$(CHECK_FILES_WRITTEN)" ""
131 RUNTEST_OPTS += --check-files-written
132 endif
133
134 RUNTEST_OPTS += \
135 --rootdir=. \
136 --config=$(CONFIG) \
137 -e 'config.confdir="$(CONFIGDIR)"' \
138 -e 'config.compiler="$(TEST_HC)"' \
139 -e 'config.compiler_always_flags.append("$(EXTRA_HC_OPTS)")' \
140 -e 'config.ghc_pkg="$(GHC_PKG)"' \
141 -e 'config.hp2ps="$(HP2PS_ABS)"' \
142 -e 'config.hpc="$(HPC)"' \
143 -e 'config.gs="$(GS)"' \
144 -e 'config.platform="$(TARGETPLATFORM)"' \
145 -e 'config.os="$(TargetOS_CPP)"' \
146 -e 'config.arch="$(TargetARCH_CPP)"' \
147 -e 'config.wordsize="$(WORDSIZE)"' \
148 -e 'default_testopts.cleanup="$(CLEANUP)"' \
149 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
150 -e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
151 -e 'config.exeext="$(exeext)"' \
152 -e 'config.top="$(TOP_ABS)"'
153
154 ifneq "$(OUTPUT_SUMMARY)" ""
155 RUNTEST_OPTS += \
156 --output-summary "$(OUTPUT_SUMMARY)"
157 endif
158
159 RUNTEST_OPTS += \
160 $(EXTRA_RUNTEST_OPTS)
161
162 ifeq "$(fast)" "YES"
163 setfast = -e config.fast=1
164 else
165 setfast =
166 endif
167
168 ifeq "$(accept)" "YES"
169 setaccept = -e config.accept=1
170 else
171 setaccept =
172 endif
173
174 TESTS =
175 TEST =
176 WAY =
177
178 .PHONY: all boot test verbose accept fast
179
180 all: test
181
182 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
183
184 boot: $(TIMEOUT_PROGRAM)
185
186 $(TIMEOUT_PROGRAM) :
187 @echo "Looks like you don't have timeout, building it first..."
188 $(MAKE) -C $(TOP)/timeout all
189
190 test: $(TIMEOUT_PROGRAM)
191 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
192 $(patsubst %, --only=%, $(TEST)) \
193 $(patsubst %, --only=%, $(TESTS)) \
194 $(patsubst %, --way=%, $(WAY)) \
195 $(patsubst %, --skipway=%, $(SKIPWAY)) \
196 $(setfast) \
197 $(setaccept)
198
199 verbose: test
200
201 accept:
202 $(MAKE) accept=YES
203
204 fast:
205 $(MAKE) fast=YES
206