Fix running dyn tests on OS X
[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 HASKELL98_LIBDIR := $(shell "$(GHC_PKG)" field haskell98 library-dirs | sed 's/^[^:]*: *//')
48 HAVE_PROFILING := $(shell if [ -f $(HASKELL98_LIBDIR)/libHShaskell98-*_p.a ]; then echo YES; else echo NO; fi)
49
50 ifeq "$(HAVE_PROFILING)" "YES"
51 RUNTEST_OPTS += -e ghc_with_profiling=1
52 else
53 RUNTEST_OPTS += -e ghc_with_profiling=0
54 endif
55
56 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
57 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
58 else
59 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
60 endif
61
62 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
63 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
64 else
65 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
66 endif
67
68 $(eval $(call get-ghc-feature-bool,GhcWithInterpreter,Have interpreter))
69 ifeq "$(GhcWithInterpreter)" "YES"
70 RUNTEST_OPTS += -e ghc_with_interpreter=1
71 else
72 RUNTEST_OPTS += -e ghc_with_interpreter=0
73 endif
74
75 $(eval $(call get-ghc-feature-bool,GhcUnregisterised,Unregisterised))
76 ifeq "$(GhcUnregisterised)" "YES"
77 RUNTEST_OPTS += -e ghc_unregisterised=1
78 else
79 RUNTEST_OPTS += -e ghc_unregisterised=0
80 endif
81
82 $(eval $(call get-ghc-feature-bool,GhcWithSMP,Support SMP))
83 ifeq "$(GhcWithSMP)" "YES"
84 RUNTEST_OPTS += -e ghc_with_smp=1
85 else
86 RUNTEST_OPTS += -e ghc_with_smp=0
87 endif
88
89 ifeq "$(WINDOWS)" "YES"
90 RUNTEST_OPTS += -e windows=True
91 else
92 RUNTEST_OPTS += -e windows=False
93 endif
94
95 ifeq "$(DARWIN)" "YES"
96 RUNTEST_OPTS += -e darwin=True
97 else
98 RUNTEST_OPTS += -e darwin=False
99 endif
100
101 ifeq "$(IN_TREE_COMPILER)" "YES"
102 RUNTEST_OPTS += -e in_tree_compiler=True
103 else
104 RUNTEST_OPTS += -e in_tree_compiler=False
105 endif
106
107 ifneq "$(THREADS)" ""
108 RUNTEST_OPTS += --threads=$(THREADS)
109 endif
110
111 RUNTEST_OPTS += \
112 --rootdir=. \
113 --config=$(CONFIG) \
114 -e 'config.confdir="$(CONFIGDIR)"' \
115 -e 'config.compiler="$(TEST_HC)"' \
116 -e 'config.compiler_always_flags.append("$(EXTRA_HC_OPTS)")' \
117 -e 'config.ghc_pkg="$(GHC_PKG)"' \
118 -e 'config.hp2ps="$(HP2PS_ABS)"' \
119 -e 'config.hpc="$(HPC)"' \
120 -e 'config.gs="$(GS)"' \
121 -e 'config.platform="$(TARGETPLATFORM)"' \
122 -e 'config.os="$(TargetOS_CPP)"' \
123 -e 'config.arch="$(TargetARCH_CPP)"' \
124 -e 'config.wordsize="$(WORDSIZE)"' \
125 -e 'default_testopts.cleanup="$(CLEANUP)"' \
126 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
127 -e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
128 -e 'config.exeext="$(exeext)"' \
129 -e 'config.top="$(TOP_ABS)"' \
130 $(EXTRA_RUNTEST_OPTS)
131
132 ifeq "$(fast)" "YES"
133 setfast = -e config.fast=1
134 else
135 setfast =
136 endif
137
138 ifeq "$(accept)" "YES"
139 setaccept = -e config.accept=1
140 else
141 setaccept =
142 endif
143
144 TESTS =
145 TEST =
146 WAY =
147
148 .PHONY: all boot test verbose accept fast
149
150 all: test
151
152 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
153
154 boot: $(TIMEOUT_PROGRAM)
155
156 $(TIMEOUT_PROGRAM) :
157 @echo "Looks like you don't have timeout, building it first..."
158 $(MAKE) -C $(TOP)/timeout all
159
160 test: $(TIMEOUT_PROGRAM)
161 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
162 $(patsubst %, --only=%, $(TEST)) \
163 $(patsubst %, --only=%, $(TESTS)) \
164 $(patsubst %, --way=%, $(WAY)) \
165 $(patsubst %, --skipway=%, $(SKIPWAY)) \
166 $(setfast) \
167 $(setaccept)
168
169 verbose: test
170
171 accept:
172 $(MAKE) accept=YES
173
174 fast:
175 $(MAKE) fast=YES
176