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