Commit b72d6735 authored by dterei's avatar dterei
Browse files

Add more safe haskell test coverage.

parent 19b71406
{-# LANGUAGE Safe #-}
module Check09 where
import Prelude
import Data.ByteString.Char8
b :: ByteString
......
{-# LANGUAGE Safe #-}
module Check10 where
import Prelude
import Data.ByteString.Char8
b :: ByteString
......
{-# LANGUAGE Safe #-}
module Main where
import M_SafePkg5
main = do
putStrLn $ show bigInt
ImpSafeOnly05.hs:4:1:
M_SafePkg5: Can't be safely imported!
The package (safePkg01-1.0) the module resides in isn't trusted.
{-# LANGUAGE Safe #-}
module Main where
import M_SafePkg5
main = do
putStrLn $ show bigInt
{-# LANGUAGE Trustworthy #-}
module Main where
import Prelude
import safe M_SafePkg6
main = putStrLn "test"
<no location info>:
The package (base) is required to be trusted but it isn't!
<no location info>:
The package (bytestring-0.10.0.0) is required to be trusted but it isn't!
{-# LANGUAGE Trustworthy #-}
module Main where
import Prelude
import safe M_SafePkg7
main = putStrLn "test"
<no location info>:
The package (base) is required to be trusted but it isn't!
<no location info>:
The package (bytestring-0.10.0.0) is required to be trusted but it isn't!
{-# LANGUAGE Trustworthy #-}
module Main where
import Prelude
import safe M_SafePkg8
main = putStrLn "test"
<no location info>:
The package (bytestring-0.10.0.0) is required to be trusted but it isn't!
{-# LANGUAGE Trustworthy #-}
module Main where
import Prelude
import safe M_SafePkg7
main = putStrLn "test"
{-# LANGUAGE Trustworthy #-}
module M_SafePkg6 where
import safe Prelude
import safe qualified Data.ByteString.Char8 as BS
s = BS.pack "Hello World"
{-# LANGUAGE Safe #-}
module M_SafePkg7 where
import Prelude
import qualified Data.ByteString.Char8 as BS
s = BS.pack "Hello World"
{-# LANGUAGE Trustworthy #-}
module M_SafePkg8 where
import Prelude
import safe qualified Data.ByteString.Char8 as BS
s = BS.pack "Hello World"
......@@ -25,7 +25,7 @@ safePkg01:
'$(TEST_HC)' --make -o setup Setup.hs -v0
'$(GHC_PKG)' init local.db
./setup configure -v0 --prefix='$(PREFIX)' --with-compiler='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS) -trust base' --with-hc-pkg='$(GHC_PKG)' --package-db='$(PKGCONF)' $(PROF)
./setup configure -v0 --prefix='$(PREFIX)' --with-compiler='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS) -fpackage-trust -trust base -trust bytestring' --with-hc-pkg='$(GHC_PKG)' --package-db='$(PKGCONF)' $(PROF)
./setup build -v0
./setup copy -v0
./setup register --inplace -v0
......@@ -47,6 +47,15 @@ safePkg01:
echo 'M_SafePkg5'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg5.hi | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg6'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg6.hi | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg7'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg7.hi | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
echo 'M_SafePkg8'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg8.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
......@@ -54,3 +63,4 @@ safePkg01:
$(LGHC_PKG) field safePkg01-1.0 trusted
$(LGHC_PKG) distrust safePkg01-1.0
$(LGHC_PKG) field safePkg01-1.0 trusted
......@@ -24,13 +24,25 @@ 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-db local.db -trust base'])
test('ImpSafeOnly01', [normal, alone], compile, ['-fpackage-trust -package-db local.db -trust base'])
test('ImpSafeOnly02', [normal, alone], compile, ['-package-db local.db -trust base -trust safePkg01'])
test('ImpSafeOnly02', [normal, alone], compile, ['-fpackage-trust -package-db local.db -trust base -trust safePkg01'])
# Fail since we enable package trust
# Fail since we enable package trust (and still need safePkg01 trusted)
test('ImpSafeOnly03', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust base'])
# Succeed since we don't enable package trust
test('ImpSafeOnly04', [normal, alone], compile, ['-package-db local.db -trust base'])
# fail due to missing trust of safePkg01, next test succeeds.
test('ImpSafeOnly05', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust base'])
test('ImpSafeOnly06', [normal, alone], compile, ['-fpackage-trust -package-db local.db -trust base -trust safePkg01'])
# fail due to missing trust
test('ImpSafeOnly07', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust safePkg01'])
test('ImpSafeOnly08', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust safePkg01'])
test('ImpSafeOnly09', [normal, alone], compile_fail, ['-fpackage-trust -package-db local.db -trust safePkg01'])
# finally succeed
test('ImpSafeOnly10', [normal, alone], compile, ['-fpackage-trust -package-db local.db -trust safePkg01 -trust base -trust bytestring'])
......@@ -5,12 +5,15 @@ License: BSD3
Build-Type: Simple
Library {
Build-Depends: base >= 4
Build-Depends: base, bytestring
Exposed-Modules:
M_SafePkg
M_SafePkg2
M_SafePkg3
M_SafePkg4
M_SafePkg5
M_SafePkg6
M_SafePkg7
M_SafePkg8
}
......@@ -28,6 +28,21 @@ package dependencies: base* ghc-prim integer-gmp
trusted: safe-inferred
require own pkg trusted: True
M_SafePkg6
package dependencies: array-0.4.0.1 base* bytestring-0.10.0.0*
trusted: trustworthy
require own pkg trusted: False
M_SafePkg7
package dependencies: array-0.4.0.1 base* bytestring-0.10.0.0*
trusted: safe
require own pkg trusted: False
M_SafePkg8
package dependencies: array-0.4.0.1 base bytestring-0.10.0.0*
trusted: trustworthy
require own pkg trusted: False
Testing setting trust
trusted: True
trusted: False
......
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