Commit 5a31abe3 authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

driver: Add test for #12983

This test has worked since 8.10.2 at least but was recently broken and
is now working again after this patch.

Closes #12983
parent 421beb3f
Pipeline #37821 failed with stages
in 14 minutes and 26 seconds
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
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
# Test for #12983, a recompilation bug with Template Haskell
test('T12983', [req_th, unless(have_dynamic(), skip), extra_files(['build.sh', 'src'])], makefile_test, [])
#!/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
{-# LANGUAGE TemplateHaskell #-}
module Main where
import qualified Types
-- splices in "string :: String"
$(Types.genCode)
main :: IO ()
main = putStrLn string
module Hospital where
import ShortText
foo :: Int -> String
foo i = toString (ShortText (show i))
module Hospital where
foo :: Int -> String
foo i = show i
module ShortText where
data ShortText = ShortText String
toString :: ShortText -> String
toString (ShortText s) = s
{-# 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|]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment