summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-01-08 16:11:00 +0000
committerIan Lynagh <igloo@earth.li>2009-01-08 16:11:00 +0000
commit2117cc225db601eed5a75f51a4ee499d2dd0a3bb (patch)
tree863b1256750d8cb7c0c8ab456141ec7d00685583
parente6fc6a9c2e9355f981f34ac9be8a5061a07a7bda (diff)
downloadhaskell-2117cc225db601eed5a75f51a4ee499d2dd0a3bb.tar.gz
Disentangle the testsuite from the compiler's build system
-rw-r--r--testsuite/mk/boilerplate.mk95
-rw-r--r--testsuite/mk/test.mk85
-rw-r--r--testsuite/mk/wordsize.mk.in5
-rw-r--r--testsuite/tests/ghc-regress/Makefile7
-rw-r--r--testsuite/timeout/Makefile21
-rw-r--r--testsuite/timeout/Setup.hs6
-rw-r--r--testsuite/timeout/ghc.mk41
-rw-r--r--testsuite/utils/Makefile14
-rw-r--r--testsuite/utils/pwd.hs26
9 files changed, 123 insertions, 177 deletions
diff --git a/testsuite/mk/boilerplate.mk b/testsuite/mk/boilerplate.mk
index 39fbefa7ad..7822c765ba 100644
--- a/testsuite/mk/boilerplate.mk
+++ b/testsuite/mk/boilerplate.mk
@@ -1,23 +1,94 @@
-TESTSUITE_TOP := $(TOP)
-TOP:=$(TOP)/..
-ifneq "$(wildcard $(TOP)/ghc.mk)" ""
-NEWBUILD=YES
+# XXX This whole file should disappear
+
+# New build system:
+# include mk/newconfig.mk
+# default : all
+
+# Old build system:
+# include mk/boilerplate.mk
+
+default: all
+
+define get-ghc-rts-field # $1 = rseult variable, $2 = field name
+$1 := $$(shell $$(TEST_HC) +RTS --info | grep '^ .("$2",' | sed -e 's/.*", *"//' -e 's/")$$$$//')
+endef
+
+define get-ghc-field # $1 = rseult variable, $2 = field name
+$1 := $$(shell $$(TEST_HC) --info | grep '^ .("$2",' | sed -e 's/.*", *"//' -e 's/")$$$$//')
+endef
+
+define get-ghc-feature-bool # $1 = rseult variable, $2 = field name
+SHELL_RES := $$(shell $$(TEST_HC) --info | grep '^ .("$2",' | sed -e 's/.*", *"//' -e 's/")$$$$//')
+$1 := $$(strip \
+ $$(if $$(SHELL_RES), \
+ $$(if $$(subst YES,,$$(SHELL_RES)), \
+ $$(if $$(subst NO,,$$(SHELL_RES)), \
+ $$(warning ghc info field not YES or NO: $2: $$(SHELL_RES)), \
+ NO), \
+ YES), \
+ $$(warning ghc info field not found: $2)))
+endef
+
+ifeq "$(TEST_HC)" ""
+
+OLD_BUILD_SYSTEM_STAGE1_GHC := $(abspath $(TOP)/../ghc/stage1-inplace/ghc)
+OLD_BUILD_SYSTEM_STAGE2_GHC := $(abspath $(TOP)/../ghc/stage2-inplace/ghc)
+OLD_BUILD_SYSTEM_STAGE3_GHC := $(abspath $(TOP)/../ghc/stage3-inplace/ghc)
+OLD_BUILD_SYSTEM_GHC_PKG := $(abspath $(TOP)/../utils/ghc-pkg/install-inplace/bin/ghc-pkg)
+OLD_BUILD_SYSTEM_HP2PS := $(abspath $(TOP)/../utils/hp2ps/hp2ps)
+ifneq "$(wildcard $(OLD_BUILD_SYSTEM_STAGE1_GHC))" ""
+
+ifeq "$(stage)" "1"
+TEST_HC := $(OLD_BUILD_SYSTEM_STAGE1_GHC)
+else
+ifeq "$(stage)" "3"
+TEST_HC := $(OLD_BUILD_SYSTEM_STAGE3_GHC)
else
-NEWBUILD=NO
+# use stage2 by default
+TEST_HC := $(OLD_BUILD_SYSTEM_STAGE2_GHC)
+endif
+GHC_PKG := $(OLD_BUILD_SYSTEM_GHC_PKG)
+HP2PS_ABS := $(OLD_BUILD_SYSTEM_HP2PS)
endif
-ifeq "$(NEWBUILD)" "YES"
+else
+NEW_BUILD_SYSTEM_STAGE1_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage1)
+NEW_BUILD_SYSTEM_STAGE2_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage2)
+NEW_BUILD_SYSTEM_STAGE3_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage3)
+ifneq "$(wildcard $(NEW_BUILD_SYSTEM_STAGE1_GHC))" ""
-FPTOOLS_TOP:=$(TOP)
-include $(FPTOOLS_TOP)/mk/newconfig.mk
+else
+TEST_HC := $(shell which ghc)
+endif
+
+endif
+endif
-default : all
+ifeq "$(GHC_PKG)" ""
+GHC_PKG := $(dir $(TEST_HC))/ghc-pkg
+endif
-else
+ifeq "$(HP2PS_ABS)" ""
+HP2PS_ABS := $(dir $(TEST_HC))/hp2ps
+endif
+
+ifeq "$(wildcard $(TEST_HC))" ""
+$(error Cannot find ghc)
+endif
-include $(TOP)/mk/boilerplate.mk
+ifeq "$(wildcard $(GHC_PKG))" ""
+$(error Cannot find ghc-pkg)
+endif
+ifeq "$(wildcard $(HP2PS_ABS))" ""
+$(error Cannot find hp2ps)
endif
-TOP:=$(TESTSUITE_TOP)
+$(eval $(call get-ghc-field,GhcRTSWays,RTS ways))
+
+GS = gs
+CP = cp
+RM = rm -f
+PYTHON = /usr/bin/python
+
diff --git a/testsuite/mk/test.mk b/testsuite/mk/test.mk
index 5695876b10..87c4327386 100644
--- a/testsuite/mk/test.mk
+++ b/testsuite/mk/test.mk
@@ -17,76 +17,59 @@
#
# -----------------------------------------------------------------------------
-include $(TOP)/mk/wordsize.mk
-
-$(TOP)/mk/wordsize.mk : $(TOP)/mk/wordsize.mk.in
- $(CPP) $(RAWCPP_FLAGS) -x c $(TOP)/mk/wordsize.mk.in > $(TOP)/mk/wordsize.mk
-
-ifeq "$(PYTHON)" ""
-$(error Python must be installed in order to use the testsuite)
-endif
-
# export the value of $MAKE for invocation in ghc-regress/driver/
export MAKE
-# ghastly hack, because the driver requires that $tool be an absolute path name.
-HP2PS_ABS = $(GHC_HP2PS_DIR_ABS)/hp2ps
-GS = gs
-
RUNTESTS = $(TOP)/driver/runtests.py
COMPILER = ghc
CONFIGDIR = $(TOP)/config
CONFIG = $(CONFIGDIR)/$(COMPILER)
-ifeq "$(NEWBUILD)" "YES"
-# can be overriden from the command line
-ifneq "$(stage)" ""
-TEST_HC = $(GHC_STAGE$(stage)_ABS)
-else
-TEST_HC = $(GHC_STAGE2_ABS)
-endif
-GHC_PKG = $(FPTOOLS_TOP_ABS)/$(GHC_PKG_INPLACE)
-else
-ifneq "$(stage)" ""
-TEST_HC = $(GHC_STAGE$(stage))
+RUNTEST_OPTS =
+
+$(eval $(call get-ghc-rts-field,WORDSIZE,Word size))
+$(eval $(call get-ghc-rts-field,TARGETPLATFORM,Target platform))
+$(eval $(call get-ghc-rts-field,TargetOS_CPP,Target OS))
+ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
+exeext =
else
-TEST_HC = $(GHC_STAGE2)
+exeext = .exe
endif
-GHC_PKG = $(GHC_PKG_INPLACE)
-endif
-
-RUNTEST_OPTS =
+$(eval $(call get-ghc-feature-bool,GhcWithNativeCodeGen,Have native code generator))
ifeq "$(GhcWithNativeCodeGen)" "YES"
RUNTEST_OPTS += -e ghc_with_native_codegen=1
else
RUNTEST_OPTS += -e ghc_with_native_codegen=0
endif
-ifeq "$(filter p, $(GhcLibWays))" "p"
+ifeq "$(filter p, $(GhcRTSWays))" "p"
RUNTEST_OPTS += -e ghc_with_profiling=1
else
RUNTEST_OPTS += -e ghc_with_profiling=0
endif
+ifeq "$(filter thr, $(GhcRTSWays))" "thr"
+RUNTEST_OPTS += -e ghc_with_threaded_rts=1
+else
+RUNTEST_OPTS += -e ghc_with_threaded_rts=0
+endif
+
+$(eval $(call get-ghc-feature-bool,GhcWithInterpreter,Have interpreter))
ifeq "$(GhcWithInterpreter)" "YES"
RUNTEST_OPTS += -e ghc_with_interpreter=1
else
RUNTEST_OPTS += -e ghc_with_interpreter=0
endif
+$(eval $(call get-ghc-feature-bool,GhcUnregisterised,Unregisterised))
ifeq "$(GhcUnregisterised)" "YES"
RUNTEST_OPTS += -e ghc_unregisterised=1
else
RUNTEST_OPTS += -e ghc_unregisterised=0
endif
-ifeq "$(filter thr, $(GhcRTSWays))" "thr"
-RUNTEST_OPTS += -e ghc_with_threaded_rts=1
-else
-RUNTEST_OPTS += -e ghc_with_threaded_rts=0
-endif
-
+$(eval $(call get-ghc-feature-bool,GhcWithSMP,Support SMP))
ifeq "$(GhcWithSMP)" "YES"
RUNTEST_OPTS += -e ghc_with_smp=1
else
@@ -102,7 +85,6 @@ RUNTEST_OPTS += \
--config=$(CONFIG) \
-e config.confdir=\"$(CONFIGDIR)\" \
-e config.compiler=\"$(TEST_HC)\" \
- -e config.compiler_always_flags.append"(\"-D$(HostPlatform_CPP)\")" \
-e config.compiler_always_flags.append"(\"$(EXTRA_HC_OPTS)\")" \
-e config.ghc_pkg=\"$(GHC_PKG)\" \
-e config.hp2ps=\"$(HP2PS_ABS)\" \
@@ -117,9 +99,6 @@ RUNTEST_OPTS += \
-e config.top=\"$(FPTOOLS_TOP_ABS)/testsuite\" \
$(EXTRA_RUNTEST_OPTS)
-# HostPlatform_CPP should ideally be TargetPlatform_CPP, but that
-# doesn't exist; they're always the same anyway
-
ifeq "$(fast)" "YES"
setfast = -e config.fast=1
else
@@ -138,36 +117,13 @@ WAY =
all :: test
-ifeq "$(NEWBUILD)" "YES"
-
-TIMEOUT_PROGRAM = $(FPTOOLS_TOP)/inplace/bin/timeout$(exeext)
-
-$(TIMEOUT_PROGRAM) :
- @echo "Looks like you don't have timeout, building it first..."
- cd $(FPTOOLS_TOP) && $(MAKE) $(MFLAGS) inplace/bin/timeout$(exeext)
-
-pwd : $(FPTOOLS_TOP)/utils/pwd$(exeext)
-
-$(FPTOOLS_TOP)/utils/pwd$(exeext) :
- @echo "Looks like you don't have pwd, building utils first..."
- cd $(FPTOOLS_TOP) && $(MAKE) $(MFLAGS) utils/pwd$(exeext)
-
-else
-
TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
$(TIMEOUT_PROGRAM) :
@echo "Looks like you don't have timeout, building it first..."
cd $(TOP)/timeout && $(MAKE) $(MFLAGS) all
-pwd : $(TOP)/utils/pwd$(exeext)
-
-$(TOP)/utils/pwd$(exeext) :
- @echo "Looks like you don't have pwd, building utils first..."
- cd $(TOP)/utils && $(MAKE) $(MFLAGS) all
-endif
-
-test: $(TIMEOUT_PROGRAM) pwd
+test: $(TIMEOUT_PROGRAM)
$(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
$(patsubst %, --only=%, $(TEST)) \
$(patsubst %, --only=%, $(TESTS)) \
@@ -183,3 +139,4 @@ accept:
fast:
$(MAKE) fast=YES
+
diff --git a/testsuite/mk/wordsize.mk.in b/testsuite/mk/wordsize.mk.in
deleted file mode 100644
index cebc7ed0a1..0000000000
--- a/testsuite/mk/wordsize.mk.in
+++ /dev/null
@@ -1,5 +0,0 @@
-
-#include "../../includes/MachDeps.h"
-
-WORDSIZE = WORD_SIZE_IN_BITS
-
diff --git a/testsuite/tests/ghc-regress/Makefile b/testsuite/tests/ghc-regress/Makefile
index 57ca568d93..0d56348ab5 100644
--- a/testsuite/tests/ghc-regress/Makefile
+++ b/testsuite/tests/ghc-regress/Makefile
@@ -4,14 +4,11 @@ include $(TOP)/mk/test.mk
# The libraries that we actually know about. We don't want to test
# extralibs that are in our tree but which we haven't built.
-ifeq "$(NEWBUILD)" "YES"
-LIBRARIES := $(shell $(FPTOOLS_TOP_ABS)/$(GHC_PKG_INPLACE) list --simple-output --names-only)
-else
LIBRARIES := $(shell $(GHC_PKG) list --simple-output --names-only)
-endif
+# XXX Do this better?
# Now find the "tests" directories of those libraries, where they exist
-LIBRARY_TEST_PATHS := $(wildcard $(patsubst %, $(FPTOOLS_TOP)/libraries/%/tests, $(LIBRARIES)))
+LIBRARY_TEST_PATHS := $(wildcard $(patsubst %, $(TOP)/../libraries/%/tests, $(LIBRARIES)))
# Add tests from packages
RUNTEST_OPTS += $(patsubst %, --rootdir=%, $(LIBRARY_TEST_PATHS))
diff --git a/testsuite/timeout/Makefile b/testsuite/timeout/Makefile
index b9f87fe746..6277009dbf 100644
--- a/testsuite/timeout/Makefile
+++ b/testsuite/timeout/Makefile
@@ -1,22 +1,23 @@
-TOP = ../..
+TOP = ..
include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/cabal-flags.mk
TIMEOUT_PROGRAM = install-inplace/bin/timeout$(exeext)
-ifeq "$(findstring thr,$(GhcRTSWays))" ""
+ifeq "$(filter thr, $(GhcRTSWays))" ""
$(TIMEOUT_PROGRAM): timeout.py
- $(MKDIRHIER) `dirname $@`
+ rm -rf install-inplace
+ mkdir install-inplace
+ mkdir install-inplace/bin
cp $< $@
chmod +x $@
else
$(TIMEOUT_PROGRAM): timeout.hs
- $(CABAL) configure $(USE_STAGE1_CONFIGURE_FLAGS) \
- $(INPLACE_DIRS_CONFIGURE_FLAGS) \
- $(COMMON_CONFIGURE_FLAGS) \
- --ghc-option=-threaded
- $(CABAL) build
- $(CABAL) install
+ rm -rf install-inplace
+ $(TEST_HC) --make Setup
+ ./Setup configure --with-compiler=$(TEST_HC) --with-hc-pkg=$(GHC_PKG) \
+ --ghc-option=-threaded --prefix=$(abspath install-inplace)
+ ./Setup build
+ ./Setup install
endif
boot all :: calibrate.out $(TIMEOUT_PROGRAM)
diff --git a/testsuite/timeout/Setup.hs b/testsuite/timeout/Setup.hs
new file mode 100644
index 0000000000..6fa548caf7
--- /dev/null
+++ b/testsuite/timeout/Setup.hs
@@ -0,0 +1,6 @@
+module Main (main) where
+
+import Distribution.Simple
+
+main :: IO ()
+main = defaultMain
diff --git a/testsuite/timeout/ghc.mk b/testsuite/timeout/ghc.mk
deleted file mode 100644
index 6d69fdda18..0000000000
--- a/testsuite/timeout/ghc.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-TIMEOUT_PROGRAM = $(INPLACE_BIN)/timeout$(exeext)
-
-ifeq "$(findstring thr,$(GhcRTSWays))" ""
-$(TIMEOUT_PROGRAM): testsuite/timeout/timeout.py
- $(MKDIRHIER) `dirname $@`
- cp $< $@
- chmod +x $@
-else
-testsuite/timeout_dist_MODULES = Main WinCBindings
-testsuite/timeout_dist_PROG = timeout
-testsuite/timeout_dist_DEP_INCLUDE_DIRS = $(GHC_INCLUDE_DIR)
-testsuite/timeout_HC_OPTS = -threaded -XCPP -package process
-ifeq "$(Windows)" "YES"
-testsuite/timeout_HC_OPTS += -package Win32
-else
-testsuite/timeout_HC_OPTS += -package unix
-endif
-
-# XXX when GHC generates dependencies it uses the module name, not the
-# filename, so we get dependencies on Main.o rather than timeout.o.
-# If we don't fix this, timeout gets compiled before the libraries.
-testsuite/timeout/dist/build/Main.hs : testsuite/timeout/timeout.hs $(MKDIRHIER)
- @$(MKDIRHIER) $(dir $@)
- $(CP) $< $@
-
-$(eval $(call build-prog,testsuite/timeout,dist,1))
-endif
-
-all : testsuite/timeout/calibrate.out
-
-# depend on $(GHC_STAGE2) so we can be sure all the libs are built
-testsuite/timeout/calibrate.out: $(GHC_STAGE2)
- $(RM) -f testsuite/timeout/TimeMe.o testsuite/timeout/TimeMe.hi testsuite/timeout/TimeMe testsuite/timeout/TimeMe.exe
- cd testsuite/timeout && $(PYTHON) calibrate "$(GHC_STAGE1_ABS)" > ../../$@
-
-CLEAN_FILES += testsuite/timeout/calibrate.out
-
-# We use stage 1 to do the calibration, as stage 2 may not exist.
-# This isn't necessarily the compiler we'll be running the testsuite
-# with, but it's really the performance of the machine that we're
-# interested in
diff --git a/testsuite/utils/Makefile b/testsuite/utils/Makefile
deleted file mode 100644
index 9255b00e80..0000000000
--- a/testsuite/utils/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ..
-include $(TOP)/mk/boilerplate.mk
-
-HC = $(GHC_INPLACE)
-
-all ::
- $(HC) --make pwd
-
-clean ::
- rm -f *.o
- rm -f *.hi
- rm -f pwd
-
-include $(TOP)/mk/target.mk
diff --git a/testsuite/utils/pwd.hs b/testsuite/utils/pwd.hs
deleted file mode 100644
index 264cc982e9..0000000000
--- a/testsuite/utils/pwd.hs
+++ /dev/null
@@ -1,26 +0,0 @@
-
-module Main where
-
-import System.Directory
-import System.Environment
-
-main :: IO ()
-main = do args <- getArgs
- let escape = case args of
- ["quadruple-backslash"] -> escape_quadruple_backslash
- ["forwardslash"] -> escape_forwardslash
- _ -> error ("pwd: Bad args: " ++ show args)
- d <- getCurrentDirectory
- putStr $ concatMap escape d
-
--- In prog006 we have to escape \ twice, once to get through sed and
--- again to get through parsing pkg.conf
-escape_quadruple_backslash :: Char -> String
-escape_quadruple_backslash '\\' = "\\\\\\\\"
-escape_quadruple_backslash c = [c]
-
--- Normally we can get away with just replacing backslashes with forwardslashes
-escape_forwardslash :: Char -> String
-escape_forwardslash '\\' = "/"
-escape_forwardslash c = [c]
-