Commit 798f3ec2 authored by dterei's avatar dterei
Browse files

Update Safe Haskell test to include recomp checks

parent 3eaeb7af
- No test for infer safe when overlapping used
- Should just the enabling of RULES make a module unsafe or only if there are actual rules defined?
- As above but with newtype deriving
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
# Here we test that recompilation detection works correctly.
# (e.g # if the safe haskell flags change, recompilation should take place)
cleanSafeRecomp01:
rm -rf SafeRecomp01.o SafeRecomp01.hi
# Just a single file
safeRecomp01:
'$(MAKE)' cleanSafeRecomp01
'$(TEST_HC)' -c SafeRecomp01.hs
'$(TEST_HC)' --show-iface SafeRecomp01.hi | grep -E '^trusted:'
'$(TEST_HC)' -XSafe -c SafeRecomp01.hs
'$(TEST_HC)' --show-iface SafeRecomp01.hi | grep -E '^trusted:'
'$(TEST_HC)' -XTrustworthy -c SafeRecomp01.hs
'$(TEST_HC)' --show-iface SafeRecomp01.hi | grep -E '^trusted:'
'$(TEST_HC)' -XUnsafe -c SafeRecomp01.hs
'$(TEST_HC)' --show-iface SafeRecomp01.hi | grep -E '^trusted:'
'$(TEST_HC)' -XUnsafe -c SafeRecomp01.hs
'$(TEST_HC)' --show-iface SafeRecomp01.hi | grep -E '^trusted:'
# what should happen when no safe haskell flag specified?
# at moment we revert to 'no flags' so we recompile if previously
# flags were specified. An alternate design would be to assume the
# safe haskell flags from the old compile still apply but we
# go with the previous design as that's the least suprise to a user.
# See [SafeRecomp02] though.
'$(TEST_HC)' -c SafeRecomp01.hs
'$(TEST_HC)' --show-iface SafeRecomp01.hi | grep -E '^trusted:'
cleanSafeRecomp02:
rm -rf SafeRecomp02 SafeRecomp02.o SafeRecomp02.hi SafeRecomp02_A.o SafeRecomp02_A.hi
# mutli module program
safeRecomp02:
'$(MAKE)' cleanSafeRecomp02
'$(TEST_HC)' -c SafeRecomp02_A.hs
'$(TEST_HC)' --make SafeRecomp02.hs
'$(TEST_HC)' --show-iface SafeRecomp02_A.hi | grep -E '^trusted:'
'$(TEST_HC)' --show-iface SafeRecomp02.hi | grep -E '^trusted:'
# Here we compile A with -XSafe but as we call --make with no flags,
# A is recompiled in 'no flag' mode. Seems a little wrong. Maybe
# we want that if a user is directly compiling a module we don't
# use any old safe haskell flags, but if we are deciding to recompile
# a module or not that was sucked up by --make, we consider no flags
# to be equivalent to old flags?
'$(TEST_HC)' -c -XSafe SafeRecomp02_A.hs
'$(TEST_HC)' --make SafeRecomp02.hs
'$(TEST_HC)' --show-iface SafeRecomp02_A.hi | grep -E '^trusted:'
'$(TEST_HC)' --show-iface SafeRecomp02.hi | grep -E '^trusted:'
# Assuming above design, we want A to be recompiled here I think as
# -XSafe was explicitly specified as part of --make.
'$(TEST_HC)' -c -XTrustworthy SafeRecomp02_A.hs
'$(TEST_HC)' --make -XSafe SafeRecomp02.hs
'$(TEST_HC)' --show-iface SafeRecomp02_A.hi | grep -E '^trusted:'
'$(TEST_HC)' --show-iface SafeRecomp02.hi | grep -E '^trusted:'
# Compiling manually so no recompilation checking
'$(TEST_HC)' -c -XTrustworthy SafeRecomp02_A.hs
'$(TEST_HC)' -c -XSafe SafeRecomp02.hs
'$(TEST_HC)' -o SafeRecomp02 SafeRecomp02.o SafeRecomp02_A.o
'$(TEST_HC)' --show-iface SafeRecomp02_A.hi | grep -E '^trusted:'
'$(TEST_HC)' --show-iface SafeRecomp02.hi | grep -E '^trusted:'
# manual compile followed by --make
'$(TEST_HC)' -c -XTrustworthy SafeRecomp02_A.hs
'$(TEST_HC)' -c -XSafe SafeRecomp02.hs
'$(TEST_HC)' --make -o SafeRecomp02 SafeRecomp02.o SafeRecomp02_A.o
'$(TEST_HC)' --show-iface SafeRecomp02_A.hi | grep -E '^trusted:'
'$(TEST_HC)' --show-iface SafeRecomp02.hi | grep -E '^trusted:'
module SafeRecomp01 where
f :: Int
f = 1
module Main where
import SafeRecomp02_A
f :: Int
f = 1
main :: IO ()
main = putStrLn $ show $ f + g
module SafeRecomp02_A where
g :: Int
g = 1
......@@ -53,3 +53,9 @@ test('SafeLang15',
['SafeLang15', '-XSafe'])
test('SafeLang16', normal, compile, [''])
# Test building a package, that trust values are set correctly
# and can be changed correctly
#test('SafeRecomp01',
# clean_cmd('$MAKE -s --no-print-directory cleanSafeRecomp01'),
# run_command, ['$MAKE -s --no-print-directory safeRecomp01'])
Markdown is supported
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