diff options
author | David Terei <davidterei@gmail.com> | 2011-10-17 20:35:28 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-10-17 20:35:28 -0700 |
commit | cca85ff0447231eb0c368e601298cfb8fbf7962c (patch) | |
tree | b237a15f49cd0ac4d544489e5e972300daff6e15 /testsuite/tests | |
parent | 29caf2acdd47ab68f460f2408c025bdc8379f36f (diff) | |
download | haskell-cca85ff0447231eb0c368e601298cfb8fbf7962c.tar.gz |
Change Safe Haskell tests for new -fpackage-trust flag
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/safeHaskell/check/all.T | 3 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/check/pkg01/ImpSafe02.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/check/pkg01/ImpSafeOnly04.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/check/pkg01/Makefile | 4 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/check/pkg01/all.T | 14 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/flags/all.T | 5 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/safeLanguage/all.T | 5 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/unsafeLibs/all.T | 6 |
9 files changed, 57 insertions, 4 deletions
diff --git a/testsuite/tests/safeHaskell/check/all.T b/testsuite/tests/safeHaskell/check/all.T index 0b8c7cb8a9..9e7868de48 100644 --- a/testsuite/tests/safeHaskell/check/all.T +++ b/testsuite/tests/safeHaskell/check/all.T @@ -1,3 +1,6 @@ +# 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'] diff --git a/testsuite/tests/safeHaskell/check/pkg01/ImpSafe02.hs b/testsuite/tests/safeHaskell/check/pkg01/ImpSafe02.hs new file mode 100644 index 0000000000..deb0d57f8d --- /dev/null +++ b/testsuite/tests/safeHaskell/check/pkg01/ImpSafe02.hs @@ -0,0 +1,12 @@ +{-# 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 + diff --git a/testsuite/tests/safeHaskell/check/pkg01/ImpSafeOnly04.hs b/testsuite/tests/safeHaskell/check/pkg01/ImpSafeOnly04.hs new file mode 100644 index 0000000000..d09e39937d --- /dev/null +++ b/testsuite/tests/safeHaskell/check/pkg01/ImpSafeOnly04.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE Safe #-} +module Main where + +import M_SafePkg3 + +main = do + putStrLn $ show bigInt + diff --git a/testsuite/tests/safeHaskell/check/pkg01/Makefile b/testsuite/tests/safeHaskell/check/pkg01/Makefile index 740143fcb9..1c34906a03 100644 --- a/testsuite/tests/safeHaskell/check/pkg01/Makefile +++ b/testsuite/tests/safeHaskell/check/pkg01/Makefile @@ -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 diff --git a/testsuite/tests/safeHaskell/check/pkg01/all.T b/testsuite/tests/safeHaskell/check/pkg01/all.T index 98dbebdd87..aff23ebd57 100644 --- a/testsuite/tests/safeHaskell/check/pkg01/all.T +++ b/testsuite/tests/safeHaskell/check/pkg01/all.T @@ -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']) diff --git a/testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout b/testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout index 13a91d3610..9a98bacd8c 100644 --- a/testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout +++ b/testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout @@ -1,7 +1,7 @@ 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 diff --git a/testsuite/tests/safeHaskell/flags/all.T b/testsuite/tests/safeHaskell/flags/all.T index 7848b8328d..85b4443752 100644 --- a/testsuite/tests/safeHaskell/flags/all.T +++ b/testsuite/tests/safeHaskell/flags/all.T @@ -1,3 +1,8 @@ +# 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'] diff --git a/testsuite/tests/safeHaskell/safeLanguage/all.T b/testsuite/tests/safeHaskell/safeLanguage/all.T index 89972e7d1d..cd31bf570c 100644 --- a/testsuite/tests/safeHaskell/safeLanguage/all.T +++ b/testsuite/tests/safeHaskell/safeLanguage/all.T @@ -1,3 +1,8 @@ +# 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'] diff --git a/testsuite/tests/safeHaskell/unsafeLibs/all.T b/testsuite/tests/safeHaskell/unsafeLibs/all.T index 56969dbfd7..c43fe0d191 100644 --- a/testsuite/tests/safeHaskell/unsafeLibs/all.T +++ b/testsuite/tests/safeHaskell/unsafeLibs/all.T @@ -1,3 +1,7 @@ +# 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', '']) |