Commit cca85ff0 authored by dterei's avatar dterei

Change Safe Haskell tests for new -fpackage-trust flag

parent 29caf2ac
# check tests are about checking that the transitive safety
# check of safe haskell is working properly.
# Just do the normal way, SafeHaskell is all in the frontend
def f( opts ):
opts.only_ways = ['normal']
......
{-# LANGUAGE Safe #-}
{-# LANGUAGE NoImplicitPrelude #-}
module ImpSafe ( MyWord ) where
-- While Data.Word is safe it imports trustworthy
-- modules in base, hence base needs to be trusted.
-- Note: Worthwhile giving out better error messages for cases
-- like this if I can.
import Data.Word
type MyWord = Word
{-# LANGUAGE Safe #-}
module Main where
import M_SafePkg3
main = do
putStrLn $ show bigInt
......@@ -45,5 +45,9 @@ safePkg01:
'$(TEST_HC)' --show-iface dist/build/M_SafePkg4.hi | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'Testing setting trust'
$(LGHC_PKG) trust safePkg01-1.0
$(LGHC_PKG) field safePkg01-1.0 trusted
$(LGHC_PKG) distrust safePkg01-1.0
$(LGHC_PKG) field safePkg01-1.0 trusted
$(LGHC_PKG) distrust safePkg01-1.0
$(LGHC_PKG) field safePkg01-1.0 trusted
......@@ -9,6 +9,8 @@ if config.have_profiling:
else:
prof = ''
# Test building a package, that trust values are set correctly
# and can be changed correctly
test('safePkg01',
[# TODO: The other tests in here depend on this one not being cleaned
# clean_cmd('$MAKE -s --no-print-directory cleanSafePkg01'),
......@@ -16,11 +18,19 @@ test('safePkg01',
run_command,
['$MAKE -s --no-print-directory safePkg01 PROF=' + prof])
test('ImpSafe01', normal, compile_fail, ['-distrust base'])
# Fail since we enable package trust
test('ImpSafe01', normal, compile_fail, ['-fpackage-trust -distrust base'])
# Succeed since we don't enable package trust
test('ImpSafe02', normal, compile, ['-distrust base'])
test('ImpSafeOnly01', [normal, alone], compile, ['-package-conf local.db -trust base'])
test('ImpSafeOnly02', [normal, alone], compile, ['-package-conf local.db -trust base -trust safePkg01'])
test('ImpSafeOnly03', [normal, alone], compile_fail, ['-package-conf local.db -trust base'])
# Fail since we enable package trust
test('ImpSafeOnly03', [normal, alone], compile_fail, ['-fpackage-trust -package-conf local.db -trust base'])
# Succeed since we don't enable package trust
test('ImpSafeOnly04', [normal, alone], compile, ['-package-conf local.db -trust base'])
local.db:
safePkg01-1.0
trusted: True
trusted: False
M_SafePkg
package dependencies: base* ghc-prim integer-gmp
......@@ -24,4 +24,6 @@ trusted: safe
require own pkg trusted: True
Testing setting trust
trusted: True
trusted: False
trusted: False
# flags tests are about checking that various ghc option flags
# and some language extension flags still work. This used to
# test that safe compilation was working but now safe compilation
# has been dropped.
# Just do the normal way, SafeHaskell is all in the frontend
def f( opts ):
opts.only_ways = ['normal']
......
# safeLanguage tests are all about making sure the correct
# unsafe language extensions are disabled or restricted
# in the -XSafe language. Basically testing that -XSafe
# works correctly (incluidng testing safe imports a little).
# Just do the normal way, SafeHaskell is all in the frontend
def f( opts ):
opts.only_ways = ['normal']
......
# unsafeLib tests are all about testing that the correct
# standard library modules have been marked as unsafe.
# e.g no importing unsafePerformIO
# Just do the normal way, SafeHaskell is all in the frontend
def f( opts ):
opts.only_ways = ['normal']
......@@ -23,4 +27,4 @@ test('BadImport02',
test('BadImport03',
extra_clean(['BadImport03_A.o', 'BadImport03_A.hi']),
multimod_compile_fail,
['BadImport03', ''])
\ No newline at end of file
['BadImport03', ''])
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