diff options
-rw-r--r-- | testsuite/tests/driver/T12983/Makefile | 8 | ||||
-rw-r--r-- | testsuite/tests/driver/T12983/T12983.stdout | 41 | ||||
-rw-r--r-- | testsuite/tests/driver/T12983/all.T | 3 | ||||
-rwxr-xr-x | testsuite/tests/driver/T12983/build.sh | 57 | ||||
-rw-r--r-- | testsuite/tests/driver/T12983/src/MetaHandler.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/driver/T12983/src/New_Hospital.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/driver/T12983/src/Old_Hospital.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/driver/T12983/src/ShortText.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/driver/T12983/src/Types.hs | 10 |
9 files changed, 145 insertions, 0 deletions
diff --git a/testsuite/tests/driver/T12983/Makefile b/testsuite/tests/driver/T12983/Makefile new file mode 100644 index 0000000000..e15b2fb7da --- /dev/null +++ b/testsuite/tests/driver/T12983/Makefile @@ -0,0 +1,8 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# This makefile rule only exists because TEST_HC is set in boilerplate.mk +# and otherwise the TEST_HC variable wouldn't be set in the context of the bash script +T12983: + TEST_HC="$(TEST_HC)" ./build.sh diff --git a/testsuite/tests/driver/T12983/T12983.stdout b/testsuite/tests/driver/T12983/T12983.stdout new file mode 100644 index 0000000000..321e702d27 --- /dev/null +++ b/testsuite/tests/driver/T12983/T12983.stdout @@ -0,0 +1,41 @@ + +Preparing everyting with --make ... + +[1 of 3] Compiling Hospital +[2 of 3] Compiling Types +[3 of 3] Compiling Main +Linking src/MetaHandler ... +Done with preparations with --make + +Building with --make + +[1 of 4] Compiling ShortText +[2 of 4] Compiling Hospital [Source file changed] +[4 of 4] Compiling Main [Hospital[TH] changed] +Linking src/MetaHandler ... + +Preparing everything ... +src/Hospital.hs +src/Types.hs +src/MetaHandler.hs +Done with preparations +Building file-by-file, with -fforce-recomp + +src/ShortText.hs +src/Hospital.hs +-fforce-recomp src/Types.hs +src/MetaHandler.hs + +Preparing everything ... +src/Hospital.hs +src/Types.hs +src/MetaHandler.hs +Done with preparations + +Building file-by-file + +src/ShortText.hs +src/Hospital.hs +src/Types.hs +compilation IS NOT required +src/MetaHandler.hs diff --git a/testsuite/tests/driver/T12983/all.T b/testsuite/tests/driver/T12983/all.T new file mode 100644 index 0000000000..f5a4f4d519 --- /dev/null +++ b/testsuite/tests/driver/T12983/all.T @@ -0,0 +1,3 @@ +# Test for #12983, a recompilation bug with Template Haskell +test('T12983', [req_th, unless(have_dynamic(), skip), extra_files(['build.sh', 'src'])], makefile_test, []) + diff --git a/testsuite/tests/driver/T12983/build.sh b/testsuite/tests/driver/T12983/build.sh new file mode 100755 index 0000000000..9026802e08 --- /dev/null +++ b/testsuite/tests/driver/T12983/build.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +GHC="${TEST_HC}" + +flags="${TEST_HC_OPTS} -O0 -fhide-source-paths -isrc -ibuild -dynamic-too -outputdir build -package template-haskell" + +function compile() +{ + echo $@ + "$GHC" -c $flags $@ || exit 1 +} + +function setup() +{ + echo + echo "Preparing everything ..." + rm -rf build + mkdir -p build + cp src/Old_Hospital.hs src/Hospital.hs + compile src/Hospital.hs + compile src/Types.hs + compile src/MetaHandler.hs + echo "Done with preparations" +} + +echo +echo "Preparing everyting with --make ..." +echo +rm -rf build +mkdir -p build +cp src/Old_Hospital.hs src/Hospital.hs +"$GHC" --make $flags src/MetaHandler.hs +echo "Done with preparations with --make" +echo +echo "Building with --make" +echo +cp src/New_Hospital.hs src/Hospital.hs +"$GHC" --make $flags src/MetaHandler.hs + +setup +echo "Building file-by-file, with -fforce-recomp" +echo +cp src/New_Hospital.hs src/Hospital.hs +compile src/ShortText.hs +compile src/Hospital.hs +compile -fforce-recomp src/Types.hs +compile src/MetaHandler.hs + +setup +echo +echo "Building file-by-file" +echo +cp src/New_Hospital.hs src/Hospital.hs +compile src/ShortText.hs +compile src/Hospital.hs +compile src/Types.hs +compile src/MetaHandler.hs diff --git a/testsuite/tests/driver/T12983/src/MetaHandler.hs b/testsuite/tests/driver/T12983/src/MetaHandler.hs new file mode 100644 index 0000000000..87b48db36c --- /dev/null +++ b/testsuite/tests/driver/T12983/src/MetaHandler.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TemplateHaskell #-} +module Main where + +import qualified Types + +-- splices in "string :: String" +$(Types.genCode) + +main :: IO () +main = putStrLn string diff --git a/testsuite/tests/driver/T12983/src/New_Hospital.hs b/testsuite/tests/driver/T12983/src/New_Hospital.hs new file mode 100644 index 0000000000..2cbd21401c --- /dev/null +++ b/testsuite/tests/driver/T12983/src/New_Hospital.hs @@ -0,0 +1,6 @@ +module Hospital where + +import ShortText + +foo :: Int -> String +foo i = toString (ShortText (show i)) diff --git a/testsuite/tests/driver/T12983/src/Old_Hospital.hs b/testsuite/tests/driver/T12983/src/Old_Hospital.hs new file mode 100644 index 0000000000..4a0819ea58 --- /dev/null +++ b/testsuite/tests/driver/T12983/src/Old_Hospital.hs @@ -0,0 +1,4 @@ +module Hospital where + +foo :: Int -> String +foo i = show i diff --git a/testsuite/tests/driver/T12983/src/ShortText.hs b/testsuite/tests/driver/T12983/src/ShortText.hs new file mode 100644 index 0000000000..88ca2cf6bc --- /dev/null +++ b/testsuite/tests/driver/T12983/src/ShortText.hs @@ -0,0 +1,6 @@ +module ShortText where + +data ShortText = ShortText String + +toString :: ShortText -> String +toString (ShortText s) = s diff --git a/testsuite/tests/driver/T12983/src/Types.hs b/testsuite/tests/driver/T12983/src/Types.hs new file mode 100644 index 0000000000..20602dfd85 --- /dev/null +++ b/testsuite/tests/driver/T12983/src/Types.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TemplateHaskell #-} +module Types where + +import qualified Hospital +import Language.Haskell.TH + +genCode :: Q [Dec] +genCode = + let s = Hospital.foo 5 + in [d|string = s|] |