Disentangle the testsuite from the compiler's build system
[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 ifeq "$(filter p, $(GhcRTSWays))" "p"
47 RUNTEST_OPTS += -e ghc_with_profiling=1
48 else
49 RUNTEST_OPTS += -e ghc_with_profiling=0
50 endif
51
52 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
53 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
54 else
55 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
56 endif
57
58 $(eval $(call get-ghc-feature-bool,GhcWithInterpreter,Have interpreter))
59 ifeq "$(GhcWithInterpreter)" "YES"
60 RUNTEST_OPTS += -e ghc_with_interpreter=1
61 else
62 RUNTEST_OPTS += -e ghc_with_interpreter=0
63 endif
64
65 $(eval $(call get-ghc-feature-bool,GhcUnregisterised,Unregisterised))
66 ifeq "$(GhcUnregisterised)" "YES"
67 RUNTEST_OPTS += -e ghc_unregisterised=1
68 else
69 RUNTEST_OPTS += -e ghc_unregisterised=0
70 endif
71
72 $(eval $(call get-ghc-feature-bool,GhcWithSMP,Support SMP))
73 ifeq "$(GhcWithSMP)" "YES"
74 RUNTEST_OPTS += -e ghc_with_smp=1
75 else
76 RUNTEST_OPTS += -e ghc_with_smp=0
77 endif
78
79 ifneq "$(THREADS)" ""
80 RUNTEST_OPTS += --threads=$(THREADS)
81 endif
82
83 RUNTEST_OPTS += \
84 --rootdir=. \
85 --config=$(CONFIG) \
86 -e config.confdir=\"$(CONFIGDIR)\" \
87 -e config.compiler=\"$(TEST_HC)\" \
88 -e config.compiler_always_flags.append"(\"$(EXTRA_HC_OPTS)\")" \
89 -e config.ghc_pkg=\"$(GHC_PKG)\" \
90 -e config.hp2ps=\"$(HP2PS_ABS)\" \
91 -e config.gs=\"$(GS)\" \
92 -e config.platform=\"$(TARGETPLATFORM)\" \
93 -e config.os=\"$(TargetOS_CPP)\" \
94 -e config.wordsize=\"$(WORDSIZE)\" \
95 -e default_testopts.cleanup=\"$(CLEANUP)\" \
96 -e config.timeout="int($(TIMEOUT)) or config.timeout" \
97 -e config.timeout_prog=\"$(TIMEOUT_PROGRAM)\" \
98 -e config.exeext=\"$(exeext)\" \
99 -e config.top=\"$(FPTOOLS_TOP_ABS)/testsuite\" \
100 $(EXTRA_RUNTEST_OPTS)
101
102 ifeq "$(fast)" "YES"
103 setfast = -e config.fast=1
104 else
105 setfast =
106 endif
107
108 ifeq "$(accept)" "YES"
109 setaccept = -e config.accept=1
110 else
111 setaccept =
112 endif
113
114 TESTS =
115 TEST =
116 WAY =
117
118 all :: test
119
120 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
121
122 $(TIMEOUT_PROGRAM) :
123 @echo "Looks like you don't have timeout, building it first..."
124 cd $(TOP)/timeout && $(MAKE) $(MFLAGS) all
125
126 test: $(TIMEOUT_PROGRAM)
127 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
128 $(patsubst %, --only=%, $(TEST)) \
129 $(patsubst %, --only=%, $(TESTS)) \
130 $(patsubst %, --way=%, $(WAY)) \
131 $(patsubst %, --skipway=%, $(SKIPWAY)) \
132 $(setfast) \
133 $(setaccept)
134
135 verbose: test
136
137 accept:
138 $(MAKE) accept=YES
139
140 fast:
141 $(MAKE) fast=YES
142