Commit 00ca8c34 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Add a test for TH's qAddDependentFile

parent 5c117b6a
......@@ -17,3 +17,22 @@ TH_spliceE5_prof::
'$(TEST_HC)' $(TEST_HC_OPTS) $(HC_OPTS) --make -v0 TH_spliceE5_prof.hs -prof -auto-all -osuf p.o -o $@
.PHONY: TH_Depends
$(RM) TH_Depends_external.txt
$(RM) TH_Depends TH_Depends.exe
$(RM) TH_Depends.o TH_Depends.hi
$(RM) TH_Depends_External.o TH_Depends_External.hi
echo "first run" > TH_Depends_external.txt
'$(TEST_HC)' $(TEST_HC_OPTS) --make -v0 TH_Depends
# Remove the executable, as GHC won't relink if the timestamps seem to
# be the same
$(RM) TH_Depends TH_Depends.exe
echo "second run" > TH_Depends_external.txt
# Give TH_Depends_external.txt a future date in case it gets the same
# timestamp again
touch --date="now + 3 seconds" TH_Depends_external.txt
'$(TEST_HC)' $(TEST_HC_OPTS) --make -v0 TH_Depends
{-# LANGUAGE TemplateHaskell #-}
module Main where
import TH_Depends_External (loadStringFromFile)
main :: IO ()
main = putStrLn $loadStringFromFile
module TH_Depends_External where
import Language.Haskell.TH.Syntax
import Language.Haskell.TH.Lib
loadStringFromFile :: Q Exp
loadStringFromFile = do
let externalDependency = "TH_Depends_external.txt"
qAddDependentFile externalDependency
s <- qRunIO $ readFile externalDependency
stringE s
......@@ -208,3 +208,8 @@ test('T5452', normal, compile, ['-v0'])
test('T5434', extra_clean(['T5434a.hi','T5434a.o']),
multimod_compile, ['T5434','-v0 -Wall'])
test('T5508', normal, compile, ['-v0 -ddump-splices'])
[extra_clean(['TH_Depends_External.o', 'TH_Depends_External.hi',
['$MAKE -s --no-print-directory TH_Depends'])
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