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 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 "$(GhcDynamicByDefault)" "YES"
84 RUNTEST_OPTS += -e ghc_dynamic_by_default=True
85 else
86 RUNTEST_OPTS += -e ghc_dynamic_by_default=False
87 endif
88
89 ifeq "$(GhcWithSMP)" "YES"
90 RUNTEST_OPTS += -e ghc_with_smp=1
91 else
92 RUNTEST_OPTS += -e ghc_with_smp=0
93 endif
94
95 ifneq "$(shell $(SHELL) -c 'llc --version | grep version' 2> /dev/null)" ""
96 RUNTEST_OPTS += -e ghc_with_llvm=1
97 else
98 RUNTEST_OPTS += -e ghc_with_llvm=0
99 endif
100
101 ifeq "$(WINDOWS)" "YES"
102 RUNTEST_OPTS += -e windows=True
103 else
104 RUNTEST_OPTS += -e windows=False
105 endif
106
107 ifeq "$(DARWIN)" "YES"
108 RUNTEST_OPTS += -e darwin=True
109 else
110 RUNTEST_OPTS += -e darwin=False
111 endif
112
113 ifeq "$(IN_TREE_COMPILER)" "YES"
114 RUNTEST_OPTS += -e in_tree_compiler=True
115 else
116 RUNTEST_OPTS += -e in_tree_compiler=False
117 endif
118
119 ifneq "$(THREADS)" ""
120 RUNTEST_OPTS += --threads=$(THREADS)
121 endif
122
123 ifneq "$(CLEAN_ONLY)" ""
124 RUNTEST_OPTS += -e clean_only=True
125 else
126 RUNTEST_OPTS += -e clean_only=False
127 endif
128
129 ifneq "$(CHECK_FILES_WRITTEN)" ""
130 RUNTEST_OPTS += --check-files-written
131 endif
132
133 RUNTEST_OPTS += \
134 --rootdir=. \
135 --config=$(CONFIG) \
136 -e 'config.confdir="$(CONFIGDIR)"' \
137 -e 'config.compiler="$(TEST_HC)"' \
138 -e 'config.ghc_pkg="$(GHC_PKG)"' \
139 -e 'config.hp2ps="$(HP2PS_ABS)"' \
140 -e 'config.hpc="$(HPC)"' \
141 -e 'config.gs="$(GS)"' \
142 -e 'config.platform="$(TARGETPLATFORM)"' \
143 -e 'config.os="$(TargetOS_CPP)"' \
144 -e 'config.arch="$(TargetARCH_CPP)"' \
145 -e 'config.wordsize="$(WORDSIZE)"' \
146 -e 'default_testopts.cleanup="$(CLEANUP)"' \
147 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
148 -e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
149 -e 'config.exeext="$(exeext)"' \
150 -e 'config.top="$(TOP_ABS)"'
151
152 ifneq "$(OUTPUT_SUMMARY)" ""
153 RUNTEST_OPTS += \
154 --output-summary "$(OUTPUT_SUMMARY)"
155 endif
156
157 RUNTEST_OPTS += \
158 $(EXTRA_RUNTEST_OPTS)
159
160 ifeq "$(fast)" "YES"
161 setfast = -e config.fast=1
162 else
163 setfast =
164 endif
165
166 ifeq "$(accept)" "YES"
167 setaccept = -e config.accept=1
168 else
169 setaccept =
170 endif
171
172 TESTS =
173 TEST =
174 WAY =
175
176 .PHONY: all boot test verbose accept fast
177
178 all: test
179
180 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
181
182 boot: $(TIMEOUT_PROGRAM)
183
184 $(TIMEOUT_PROGRAM) :
185 @echo "Looks like you don't have timeout, building it first..."
186 $(MAKE) -C $(TOP)/timeout all
187
188 test: $(TIMEOUT_PROGRAM)
189 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
190 $(patsubst %, --only=%, $(TEST)) \
191 $(patsubst %, --only=%, $(TESTS)) \
192 $(patsubst %, --way=%, $(WAY)) \
193 $(patsubst %, --skipway=%, $(SKIPWAY)) \
194 $(setfast) \
195 $(setaccept)
196
197 verbose: test
198
199 accept:
200 $(MAKE) accept=YES
201
202 fast:
203 $(MAKE) fast=YES
204