[commit: packages/directory] improve-tests-for-real: Automatically run the GHC test framework (41e1131)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 11:37:44 UTC 2015


Repository : ssh://git@git.haskell.org/directory

On branch  : improve-tests-for-real
Link       : http://ghc.haskell.org/trac/ghc/changeset/41e11313bdc171ab7b570acf21622eae598a5138/directory

>---------------------------------------------------------------

commit 41e11313bdc171ab7b570acf21622eae598a5138
Author: Phil Ruffwind <rf at rufflewind.com>
Date:   Sun Mar 1 16:02:42 2015 -0500

    Automatically run the GHC test framework


>---------------------------------------------------------------

41e11313bdc171ab7b570acf21622eae598a5138
 testsuite/ghc.patch | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 testsuite/run       | 35 ++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+)

diff --git a/testsuite/ghc.patch b/testsuite/ghc.patch
new file mode 100644
index 0000000..61ce567
--- /dev/null
+++ b/testsuite/ghc.patch
@@ -0,0 +1,62 @@
+# allow ghc and its tools to be located in different directories
+--- testsuite/mk/boilerplate.mk
++++ testsuite/mk/boilerplate.mk
+@@ -56,6 +56,7 @@ TEST_HC := $(STAGE2_GHC)
+ endif
+ 
+ else
++implicit_compiler = YES
+ IN_TREE_COMPILER = NO
+ TEST_HC := $(shell which ghc)
+ endif
+@@ -87,24 +88,30 @@ endif
+ # containing spaces
+ BIN_ROOT = $(shell dirname '$(TEST_HC)')
+ 
++ifeq "$(implicit_compiler)" "YES"
++find_tool = $(shell which $(1))
++else
++find_tool = $(BIN_ROOT)/$(1)
++endif
++
+ ifeq "$(GHC_PKG)" ""
+-GHC_PKG := $(BIN_ROOT)/ghc-pkg
++GHC_PKG := $(call find_tool,ghc-pkg)
+ endif
+ 
+ ifeq "$(RUNGHC)" ""
+-RUNGHC := $(BIN_ROOT)/runghc
++RUNGHC := $(call find_tool,runghc)
+ endif
+ 
+ ifeq "$(HSC2HS)" ""
+-HSC2HS := $(BIN_ROOT)/hsc2hs
++HSC2HS := $(call find_tool,hsc2hs)
+ endif
+ 
+ ifeq "$(HP2PS_ABS)" ""
+-HP2PS_ABS := $(BIN_ROOT)/hp2ps
++HP2PS_ABS := $(call find_tool,hp2ps)
+ endif
+ 
+ ifeq "$(HPC)" ""
+-HPC := $(BIN_ROOT)/hpc
++HPC := $(call find_tool,hpc)
+ endif
+ 
+ $(eval $(call canonicaliseExecutable,TEST_HC))
+
+# 'die' is not available until GHC 7.10
+--- testsuite/timeout/timeout.hs
++++ testsuite/timeout/timeout.hs
+@@ -30,8 +30,8 @@ main = do
+       [secs,cmd] ->
+           case reads secs of
+           [(secs', "")] -> run secs' cmd
+-          _ -> die ("Can't parse " ++ show secs ++ " as a number of seconds")
+-      _ -> die ("Bad arguments " ++ show args)
++          _ -> ((>> exitFailure) . hPutStrLn stderr) ("Can't parse " ++ show secs ++ " as a number of seconds")
++      _ -> ((>> exitFailure) . hPutStrLn stderr) ("Bad arguments " ++ show args)
+ 
+ timeoutMsg :: String
+ timeoutMsg = "Timeout happened...killing process..."
diff --git a/testsuite/run b/testsuite/run
new file mode 100755
index 0000000..6725d39
--- /dev/null
+++ b/testsuite/run
@@ -0,0 +1,35 @@
+#!/bin/sh
+# run all of the tests under the `tests` directory using the GHC test
+# framework; for more info about this framework, see:
+# https://ghc.haskell.org/trac/ghc/wiki/Building/RunningTests
+#
+# arguments received by this script are passed as arguments to the `make`
+# invocation that initiates the tests
+set -e
+
+[ -z "$HSFLAGS" ] || HSFLAGS=\ $HSFLAGS
+HSFLAGS='-package-db ../dist/package.conf.inplace '$HSFLAGS
+HSFLAGS='-optP-include -optP../dist/build/autogen/cabal_macros.h '$HSFLAGS
+export HSFLAGS
+
+# download the GHC repository
+[ -d dist/testsuite/ghc ] || {
+    git clone --depth 1 https://github.com/ghc/ghc dist/testsuite/ghc
+    patch <testsuite/ghc.patch -d dist/testsuite/ghc -N -p 0 -r - || :
+}
+
+# we can't just specify `TOP` as an argument for `make` because it will
+# override `TOP` for *every* included makefile
+sed >dist/testsuite/Makefile \
+    "s|^TOP=.*$|TOP=../dist/testsuite/ghc/testsuite|" \
+    tests/Makefile
+
+# there's no way to pass arguments when `sh` is in `-s` mode, so we have to
+# write the shell commands to an actual file
+cat >dist/testsuite/run.sh <<"EOF"
+cd tests
+make -f ../dist/testsuite/Makefile WAY=normal EXTRA_HC_OPTS="$HSFLAGS" "$@"
+EOF
+
+cabal build
+exec cabal exec sh -- -e dist/testsuite/run.sh "$@"



More information about the ghc-commits mailing list