test.mk 4.8 KB
Newer Older
1 2 3
# -----------------------------------------------------------------------------
# Examples of use:
#
dterei's avatar
dterei committed
4 5 6
#  make           -- run all the tests in the current directory
#  make verbose   -- as make test, but up the verbosity
#  make accept    -- run the tests, accepting the current output
7 8 9
#
# The following variables may be set on the make command line:
#
dterei's avatar
dterei committed
10 11 12 13 14 15 16
#  TEST      -- specific test to run
#  TESTS     -- specific tests to run (same as $TEST really)
#  EXTRA_HC_OPTS      -- extra flags to send to the Haskell compiler
#  EXTRA_RUNTEST_OPTS -- extra flags to give the test driver
#  CONFIG    -- use a different configuration file
#  COMPILER  -- select a configuration file from config/
#  THREADS   -- run n tests at once
17 18 19
#
# -----------------------------------------------------------------------------

20
# export the value of $MAKE for invocation in tests/driver/
dons's avatar
dons committed
21 22
export MAKE

23
RUNTESTS     = $(TOP)/driver/runtests.py
ross's avatar
ross committed
24
COMPILER     = ghc
25 26
CONFIGDIR    = $(TOP)/config
CONFIG       = $(CONFIGDIR)/$(COMPILER)
27

28 29
# TEST_HC_OPTS is passed to every invocation of TEST_HC 
# in nested Makefiles
30
TEST_HC_OPTS = -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts $(EXTRA_HC_OPTS)
31

32 33 34 35
RUNTEST_OPTS =

ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
exeext =
36
else
37
exeext = .exe
38
endif
39

40 41
RUNTEST_OPTS += -e ghc_compiler_always_flags="'$(TEST_HC_OPTS)'"

42
ifeq "$(GhcWithNativeCodeGen)" "YES"
43 44 45
RUNTEST_OPTS += -e ghc_with_native_codegen=1
else
RUNTEST_OPTS += -e ghc_with_native_codegen=0
46 47
endif

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 53 54
RUNTEST_OPTS += -e ghc_with_profiling=1
else
RUNTEST_OPTS += -e ghc_with_profiling=0
55
endif
56

57 58 59 60 61 62
ifeq "$(filter thr, $(GhcRTSWays))" "thr"
RUNTEST_OPTS += -e ghc_with_threaded_rts=1
else
RUNTEST_OPTS += -e ghc_with_threaded_rts=0
endif

63 64 65 66 67 68
ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
else
RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
endif

69 70 71
ifeq "$(GhcWithInterpreter)" "NO"
RUNTEST_OPTS += -e ghc_with_interpreter=0
else ifeq "$(GhcStage)" "1"
72
RUNTEST_OPTS += -e ghc_with_interpreter=0
73 74
else
RUNTEST_OPTS += -e ghc_with_interpreter=1
75 76
endif

77 78 79 80 81 82
ifeq "$(GhcUnregisterised)" "YES"
RUNTEST_OPTS += -e ghc_unregisterised=1
else
RUNTEST_OPTS += -e ghc_unregisterised=0
endif

83 84 85 86 87 88
ifeq "$(GhcWithSMP)" "YES"
RUNTEST_OPTS += -e ghc_with_smp=1
else
RUNTEST_OPTS += -e ghc_with_smp=0
endif

dterei's avatar
dterei committed
89
ifneq "$(shell $(SHELL) -c 'llc --version | grep version' 2> /dev/null)" ""
90 91 92 93 94
RUNTEST_OPTS += -e ghc_with_llvm=1
else
RUNTEST_OPTS += -e ghc_with_llvm=0
endif

Ian Lynagh's avatar
Ian Lynagh committed
95 96 97 98 99 100
ifeq "$(WINDOWS)" "YES"
RUNTEST_OPTS += -e windows=True
else
RUNTEST_OPTS += -e windows=False
endif

Ian Lynagh's avatar
Ian Lynagh committed
101 102 103 104 105 106
ifeq "$(DARWIN)" "YES"
RUNTEST_OPTS += -e darwin=True
else
RUNTEST_OPTS += -e darwin=False
endif

107 108 109 110 111 112
ifeq "$(IN_TREE_COMPILER)" "YES"
RUNTEST_OPTS += -e in_tree_compiler=True
else
RUNTEST_OPTS += -e in_tree_compiler=False
endif

ei@vuokko.info's avatar
ei@vuokko.info committed
113
ifneq "$(THREADS)" ""
114
RUNTEST_OPTS += --threads=$(THREADS)
ei@vuokko.info's avatar
ei@vuokko.info committed
115 116
endif

117 118 119 120 121 122
ifneq "$(CLEAN_ONLY)" ""
RUNTEST_OPTS += -e clean_only=True
else
RUNTEST_OPTS += -e clean_only=False
endif

123 124 125 126
ifneq "$(CHECK_FILES_WRITTEN)" ""
RUNTEST_OPTS += --check-files-written
endif

127
RUNTEST_OPTS +=  \
128
	--rootdir=. \
129
	--config=$(CONFIG) \
Ian Lynagh's avatar
Ian Lynagh committed
130 131 132 133 134 135 136 137 138
	-e 'config.confdir="$(CONFIGDIR)"' \
	-e 'config.compiler="$(TEST_HC)"' \
	-e 'config.compiler_always_flags.append("$(EXTRA_HC_OPTS)")' \
	-e 'config.ghc_pkg="$(GHC_PKG)"' \
	-e 'config.hp2ps="$(HP2PS_ABS)"' \
	-e 'config.hpc="$(HPC)"' \
	-e 'config.gs="$(GS)"' \
	-e 'config.platform="$(TARGETPLATFORM)"' \
	-e 'config.os="$(TargetOS_CPP)"' \
139
	-e 'config.arch="$(TargetARCH_CPP)"' \
Ian Lynagh's avatar
Ian Lynagh committed
140 141
	-e 'config.wordsize="$(WORDSIZE)"' \
	-e 'default_testopts.cleanup="$(CLEANUP)"' \
Ian Lynagh's avatar
Ian Lynagh committed
142
	-e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
Ian Lynagh's avatar
Ian Lynagh committed
143 144
	-e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
	-e 'config.exeext="$(exeext)"' \
145 146 147 148 149 150 151 152
	-e 'config.top="$(TOP_ABS)"'

ifneq "$(OUTPUT_SUMMARY)" ""
RUNTEST_OPTS +=  \
	--output-summary "$(OUTPUT_SUMMARY)"
endif

RUNTEST_OPTS +=  \
153 154
	$(EXTRA_RUNTEST_OPTS)

155 156 157 158 159 160 161 162 163 164 165 166
ifeq "$(fast)" "YES"
setfast = -e config.fast=1
else
setfast = 
endif

ifeq "$(accept)" "YES"
setaccept = -e config.accept=1
else
setaccept = 
endif

167
TESTS	     = 
168
TEST	     = 
169
WAY =
170

171 172 173 174
.PHONY: all boot test verbose accept fast

all: test

175
TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
176

177 178
boot: $(TIMEOUT_PROGRAM)

179
$(TIMEOUT_PROGRAM) :
180
	@echo "Looks like you don't have timeout, building it first..."
Ian Lynagh's avatar
Ian Lynagh committed
181
	$(MAKE) -C $(TOP)/timeout all
182

183
test: $(TIMEOUT_PROGRAM)
184
	$(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
185
		$(patsubst %, --only=%, $(TEST)) \
186
		$(patsubst %, --only=%, $(TESTS)) \
187
		$(patsubst %, --way=%, $(WAY)) \
188
		$(patsubst %, --skipway=%, $(SKIPWAY)) \
189
		$(setfast) \
190
		$(setaccept)
191

192
verbose: test
193 194

accept:
195 196 197
	$(MAKE) accept=YES

fast:
198
	$(MAKE) fast=YES
199