Allow tests to behave differently depending on whether the compiler is in-tree
[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 ghc-regress/driver/
21 export MAKE
22
23 RUNTESTS = $(TOP)/driver/runtests.py
24 COMPILER = ghc
25 CONFIGDIR = $(TOP)/config
26 CONFIG = $(CONFIGDIR)/$(COMPILER)
27
28 RUNTEST_OPTS =
29
30 $(eval $(call get-ghc-rts-field,WORDSIZE,Word size))
31 $(eval $(call get-ghc-rts-field,TARGETPLATFORM,Target platform))
32 $(eval $(call get-ghc-rts-field,TargetOS_CPP,Target OS))
33 $(eval $(call get-ghc-rts-field,TargetARCH_CPP,Target architecture))
34 ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
35 exeext =
36 else
37 exeext = .exe
38 endif
39
40 $(eval $(call get-ghc-feature-bool,GhcWithNativeCodeGen,Have native code generator))
41 ifeq "$(GhcWithNativeCodeGen)" "YES"
42 RUNTEST_OPTS += -e ghc_with_native_codegen=1
43 else
44 RUNTEST_OPTS += -e ghc_with_native_codegen=0
45 endif
46
47 HAVE_PROFILING:=$(if $(wildcard $(shell "$(GHC_PKG)" field haskell98 library-dirs | sed 's/^[^:]*: *//')/libHShaskell98-*_p.a),YES,NO)
48
49 ifeq "$(HAVE_PROFILING)" "YES"
50 RUNTEST_OPTS += -e ghc_with_profiling=1
51 else
52 RUNTEST_OPTS += -e ghc_with_profiling=0
53 endif
54
55 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
56 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
57 else
58 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
59 endif
60
61 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
62 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
63 else
64 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
65 endif
66
67 $(eval $(call get-ghc-feature-bool,GhcWithInterpreter,Have interpreter))
68 ifeq "$(GhcWithInterpreter)" "YES"
69 RUNTEST_OPTS += -e ghc_with_interpreter=1
70 else
71 RUNTEST_OPTS += -e ghc_with_interpreter=0
72 endif
73
74 $(eval $(call get-ghc-feature-bool,GhcUnregisterised,Unregisterised))
75 ifeq "$(GhcUnregisterised)" "YES"
76 RUNTEST_OPTS += -e ghc_unregisterised=1
77 else
78 RUNTEST_OPTS += -e ghc_unregisterised=0
79 endif
80
81 $(eval $(call get-ghc-feature-bool,GhcWithSMP,Support SMP))
82 ifeq "$(GhcWithSMP)" "YES"
83 RUNTEST_OPTS += -e ghc_with_smp=1
84 else
85 RUNTEST_OPTS += -e ghc_with_smp=0
86 endif
87
88 ifeq "$(WINDOWS)" "YES"
89 RUNTEST_OPTS += -e windows=True
90 else
91 RUNTEST_OPTS += -e windows=False
92 endif
93
94 ifeq "$(IN_TREE_COMPILER)" "YES"
95 RUNTEST_OPTS += -e in_tree_compiler=True
96 else
97 RUNTEST_OPTS += -e in_tree_compiler=False
98 endif
99
100 ifneq "$(THREADS)" ""
101 RUNTEST_OPTS += --threads=$(THREADS)
102 endif
103
104 RUNTEST_OPTS += \
105 --rootdir=. \
106 --config=$(CONFIG) \
107 -e 'config.confdir="$(CONFIGDIR)"' \
108 -e 'config.compiler="$(TEST_HC)"' \
109 -e 'config.compiler_always_flags.append("$(EXTRA_HC_OPTS)")' \
110 -e 'config.ghc_pkg="$(GHC_PKG)"' \
111 -e 'config.hp2ps="$(HP2PS_ABS)"' \
112 -e 'config.hpc="$(HPC)"' \
113 -e 'config.gs="$(GS)"' \
114 -e 'config.platform="$(TARGETPLATFORM)"' \
115 -e 'config.os="$(TargetOS_CPP)"' \
116 -e 'config.arch="$(TargetARCH_CPP)"' \
117 -e 'config.wordsize="$(WORDSIZE)"' \
118 -e 'default_testopts.cleanup="$(CLEANUP)"' \
119 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
120 -e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
121 -e 'config.exeext="$(exeext)"' \
122 -e 'config.top="$(TOP_ABS)"' \
123 $(EXTRA_RUNTEST_OPTS)
124
125 ifeq "$(fast)" "YES"
126 setfast = -e config.fast=1
127 else
128 setfast =
129 endif
130
131 ifeq "$(accept)" "YES"
132 setaccept = -e config.accept=1
133 else
134 setaccept =
135 endif
136
137 TESTS =
138 TEST =
139 WAY =
140
141 .PHONY: all boot test verbose accept fast
142
143 all: test
144
145 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
146
147 boot: $(TIMEOUT_PROGRAM)
148
149 $(TIMEOUT_PROGRAM) :
150 @echo "Looks like you don't have timeout, building it first..."
151 $(MAKE) -C $(TOP)/timeout all
152
153 test: $(TIMEOUT_PROGRAM)
154 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
155 $(patsubst %, --only=%, $(TEST)) \
156 $(patsubst %, --only=%, $(TESTS)) \
157 $(patsubst %, --way=%, $(WAY)) \
158 $(patsubst %, --skipway=%, $(SKIPWAY)) \
159 $(setfast) \
160 $(setaccept)
161
162 verbose: test
163
164 accept:
165 $(MAKE) accept=YES
166
167 fast:
168 $(MAKE) fast=YES
169