Add more Safe Haskell tests for new design
authorDavid Terei <davidterei@gmail.com>
Thu, 20 Oct 2011 03:02:06 +0000 (20:02 -0700)
committerDavid Terei <davidterei@gmail.com>
Tue, 25 Oct 2011 21:47:31 +0000 (14:47 -0700)
37 files changed:
testsuite/driver/testlib.py
testsuite/tests/safeHaskell/flags/SafeFlags03.hs
testsuite/tests/safeHaskell/flags/SafeFlags03.stderr
testsuite/tests/safeHaskell/flags/SafeFlags05.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/flags/SafeFlags06.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/flags/SafeFlags13.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/flags/SafeFlags14.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/flags/SafeFlags16.hs
testsuite/tests/safeHaskell/flags/SafeFlags17.hs
testsuite/tests/safeHaskell/flags/SafeFlags17.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/flags/SafeFlags18.hs
testsuite/tests/safeHaskell/flags/SafeFlags19.hs
testsuite/tests/safeHaskell/flags/SafeFlags19.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/flags/SafeFlags20.hs [new file with mode: 0644]
testsuite/tests/safeHaskell/flags/all.T
testsuite/tests/safeHaskell/safeInfered/Mixed01.hs
testsuite/tests/safeHaskell/safeInfered/Mixed01.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/Mixed02.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/SafeInfered01.hs
testsuite/tests/safeHaskell/safeInfered/SafeInfered02_A.hs
testsuite/tests/safeHaskell/safeInfered/SafeInfered03_A.hs
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06_A.hs
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07_A.hs
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09.stderr [new file with mode: 0644]
testsuite/tests/safeHaskell/safeLanguage/SafeLang12.hs
testsuite/tests/safeHaskell/unsafeLibs/BadImport05.hs
testsuite/tests/safeHaskell/unsafeLibs/BadImport07.hs
testsuite/tests/safeHaskell/unsafeLibs/BadImport08.hs
testsuite/tests/safeHaskell/unsafeLibs/GoodImport03.stderr [new file with mode: 0644]

index 319ed9d..9e0252c 100644 (file)
@@ -945,9 +945,9 @@ def checkStats(stats_file, num_fields):
 def extras_build( way, extra_mods, extra_hc_opts ):
     for modopts in extra_mods:
         mod, opts = modopts
-        result = simple_build( mod, way, opts + extra_hc_opts, 0, '', 0, 0, 0)
-        if not (mod.endswith(".hs") or mod.endswith(".lhs")):
-            extra_hc_opts += " " + replace_suffix(mod, 'o')
+        result = simple_build( mod, way, opts + ' ' + extra_hc_opts, 0, '', 0, 0, 0)
+        if not (mod.endswith('.hs') or mod.endswith('.lhs')):
+            extra_hc_opts += ' ' + replace_suffix(mod, 'o')
         if badResult(result):
             return result
 
index ea83a06..0ef1561 100644 (file)
@@ -1,4 +1,4 @@
-{-# LANGUAGE SafeImports #-}
+{-# LANGUAGE SafeImport #-}
 
 -- | Basic test to see if Safe flags compiles
 module SafeFlags03 where
index 7e38ffd..0ca3951 100644 (file)
@@ -1,2 +1,2 @@
 
-SafeFlags04.hs:1:14: Unsupported extension: SafeImport
+SafeFlags03.hs:1:14: Unsupported extension: SafeImport
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags05.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags05.stderr
new file mode 100644 (file)
index 0000000..3ca3d81
--- /dev/null
@@ -0,0 +1,2 @@
+ghc-stage2: SafeFlags05.hs:1:20-25: Incompatible Safe Haskell flags! (Safe, Unsafe)
+Usage: For basic information, try the `--help' option.
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags06.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags06.stderr
new file mode 100644 (file)
index 0000000..f43309c
--- /dev/null
@@ -0,0 +1,2 @@
+ghc-stage2: SafeFlags06.hs:1:27-32: Incompatible Safe Haskell flags! (Trustworthy, Unsafe)
+Usage: For basic information, try the `--help' option.
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags13.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags13.stderr
new file mode 100644 (file)
index 0000000..9c128f5
--- /dev/null
@@ -0,0 +1,2 @@
+ghc-stage2: SafeFlags13.hs:2:14-19: Incompatible Safe Haskell flags! (Trustworthy, Unsafe)
+Usage: For basic information, try the `--help' option.
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags14.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags14.stderr
new file mode 100644 (file)
index 0000000..991511f
--- /dev/null
@@ -0,0 +1,2 @@
+ghc-stage2: SafeFlags14.hs:2:14-19: Incompatible Safe Haskell flags! (Safe, Unsafe)
+Usage: For basic information, try the `--help' option.
index 6259edc..897a7bc 100644 (file)
@@ -1,7 +1,7 @@
 {-# LANGUAGE Trustworthy #-}
 {-# OPTIONS_GHC -fpackage-trust #-}
 -- | Basic test to see if Safe flags compiles
-module SafeFlags15 where
+module SafeFlags16 where
 
 f :: Int
 f = 1
index 3f4651b..9bbd7a0 100644 (file)
@@ -1,7 +1,7 @@
 {-# LANGUAGE Safe #-}
 {-# OPTIONS_GHC -fpackage-trust #-}
 -- | Basic test to see if Safe flags compiles
-module SafeFlags15 where
+module SafeFlags17 where
 
 f :: Int
 f = 1
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags17.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags17.stderr
new file mode 100644 (file)
index 0000000..99147ee
--- /dev/null
@@ -0,0 +1,3 @@
+
+SafeFlags17.hs:4:8:
+    base:Prelude can't be safely imported! The package (base) the module resides in isn't trusted.
index f828691..601a8e0 100644 (file)
@@ -1,6 +1,6 @@
 {-# OPTIONS_GHC -fpackage-trust #-}
 -- | Basic test to see if Safe flags compiles
-module SafeFlags15 where
+module SafeFlags18 where
 
 f :: Int
 f = 1
index 957a906..053bc56 100644 (file)
@@ -2,7 +2,7 @@
 -- | Basic test to see if Safe flags compiles
 -- test should fail as there shouldn't be a no-package-trust flag, only a
 -- package-trust flag!
-module SafeFlags15 where
+module SafeFlags19 where
 
 f :: Int
 f = 1
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags19.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags19.stderr
new file mode 100644 (file)
index 0000000..adbc757
--- /dev/null
@@ -0,0 +1,3 @@
+
+SafeFlags19.hs:1:16:
+    unknown flag in  {-# OPTIONS_GHC #-} pragma: -fno-package-trust
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags20.hs b/testsuite/tests/safeHaskell/flags/SafeFlags20.hs
new file mode 100644 (file)
index 0000000..8d415c1
--- /dev/null
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+{-# OPTIONS_GHC -fpackage-trust #-}
+-- | Basic test to see if Safe flags compiles
+module SafeFlags20 where
+
+f :: Int
+f = 1
+
index 66d07b9..1100ced 100644 (file)
@@ -36,9 +36,10 @@ test('SafeFlags14', normal, compile_fail, [''])
 
 test('SafeFlags15', normal, compile, [''])
 test('SafeFlags16', normal, compile, [''])
-test('SafeFlags17', normal, compile, [''])
+test('SafeFlags17', normal, compile_fail, ['-distrust base'])
 test('SafeFlags18', normal, compile, [''])
 test('SafeFlags19', normal, compile_fail, [''])
+test('SafeFlags20', normal, compile, ['-trust base'])
 
 test('Flags01', normal, compile, [''])
 test('Flags02', normal, compile, [''])
index cb895fe..ab3497c 100644 (file)
@@ -1,7 +1,8 @@
 -- | Should fail compilation because safe imports aren't enabled
+-- not because of trying to import an unsafe module
 module Mixed01 where
 
-import safe Data.Word
+import safe System.IO.Unsafe
 
 f :: Int
 f = 1
diff --git a/testsuite/tests/safeHaskell/safeInfered/Mixed01.stderr b/testsuite/tests/safeHaskell/safeInfered/Mixed01.stderr
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testsuite/tests/safeHaskell/safeInfered/Mixed02.stderr b/testsuite/tests/safeHaskell/safeInfered/Mixed02.stderr
new file mode 100644 (file)
index 0000000..b170a45
--- /dev/null
@@ -0,0 +1,3 @@
+
+Mixed02.hs:5:1:
+    Module DW is imported both as a safe and unsafe import!
index 1562a18..0e48580 100644 (file)
@@ -1,7 +1,7 @@
 {-# LANGUAGE Safe #-}
 module SafeInfered01 where
 
-import safe SafeInfered01_A.hs
+import safe SafeInfered01_A
 
 g :: Int
 g = f
index fff3286..57438d2 100644 (file)
@@ -1,3 +1,4 @@
+{-# LANGUAGE DeriveDataTypeable #-}
 -- | Only uses deriving of Typeable so should be considered safe
 module SafeInfered02_A where
 
index 01c2839..9844ec6 100644 (file)
@@ -2,5 +2,7 @@
 -- | FFI but in IO monad so safe
 module SafeInfered03_A where
 
+import Foreign.C
+
 foreign import ccall "math.h" sin :: CDouble -> IO CDouble
 
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01.stderr
new file mode 100644 (file)
index 0000000..15212f3
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Compiling UnsafeInfered01_A ( UnsafeInfered01_A.hs, UnsafeInfered01_A.o )
+[2 of 2] Compiling UnsafeInfered01  ( UnsafeInfered01.hs, UnsafeInfered01.o )
+
+UnsafeInfered01.hs:4:1:
+    main:UnsafeInfered01_A can't be safely imported! The module itself isn't safe.
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02.stderr
new file mode 100644 (file)
index 0000000..587b8a9
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Compiling UnsafeInfered02_A ( UnsafeInfered02_A.hs, UnsafeInfered02_A.o )
+[2 of 2] Compiling UnsafeInfered02  ( UnsafeInfered02.hs, UnsafeInfered02.o )
+
+UnsafeInfered02.hs:4:1:
+    main:UnsafeInfered02_A can't be safely imported! The module itself isn't safe.
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03.stderr
new file mode 100644 (file)
index 0000000..f869206
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Compiling UnsafeInfered03_A ( UnsafeInfered03_A.hs, UnsafeInfered03_A.o )
+[2 of 2] Compiling UnsafeInfered03  ( UnsafeInfered03.hs, UnsafeInfered03.o )
+
+UnsafeInfered03.hs:4:1:
+    main:UnsafeInfered03_A can't be safely imported! The module itself isn't safe.
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04.stderr
new file mode 100644 (file)
index 0000000..0db998c
--- /dev/null
@@ -0,0 +1,2 @@
+
+UnsafeInfered04_A.hs:1:14: Unsupported extension: RULES
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05.stderr
new file mode 100644 (file)
index 0000000..e08d2ae
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Compiling UnsafeInfered05_A ( UnsafeInfered05_A.hs, UnsafeInfered05_A.o )
+[2 of 2] Compiling UnsafeInfered05  ( UnsafeInfered05.hs, UnsafeInfered05.o )
+
+UnsafeInfered05.hs:4:1:
+    main:UnsafeInfered05_A can't be safely imported! The module itself isn't safe.
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06.stderr
new file mode 100644 (file)
index 0000000..55f9166
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Compiling UnsafeInfered06_A ( UnsafeInfered06_A.hs, UnsafeInfered06_A.o )
+[2 of 2] Compiling UnsafeInfered06  ( UnsafeInfered06.hs, UnsafeInfered06.o )
+
+UnsafeInfered06.hs:4:1:
+    main:UnsafeInfered06_A can't be safely imported! The module itself isn't safe.
index f865193..1a04b69 100644 (file)
@@ -2,5 +2,7 @@
 -- | Unsafe as uses FFI with a pure function
 module UnsafeInfered06_A where
 
+import Foreign.C
+
 foreign import ccall "math.h" sin :: CDouble -> CDouble
 
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07.stderr
new file mode 100644 (file)
index 0000000..86c4717
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Compiling UnsafeInfered07_A ( UnsafeInfered07_A.hs, UnsafeInfered07_A.o )
+[2 of 2] Compiling UnsafeInfered07  ( UnsafeInfered07.hs, UnsafeInfered07.o )
+
+UnsafeInfered07.hs:4:1:
+    main:UnsafeInfered07_A can't be safely imported! The module itself isn't safe.
index 98e9249..ffc1159 100644 (file)
@@ -6,5 +6,5 @@ import Data.Typeable
 data G = G Int
 
 instance Typeable G where
-    typeof _ = typeof (undefined::Int)
+    typeOf _ = typeOf (undefined::Int)
 
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08.stderr
new file mode 100644 (file)
index 0000000..b204c68
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Compiling UnsafeInfered08_A ( UnsafeInfered08_A.hs, UnsafeInfered08_A.o )
+[2 of 2] Compiling UnsafeInfered08  ( UnsafeInfered08.hs, UnsafeInfered08.o )
+
+UnsafeInfered08.hs:4:1:
+    main:UnsafeInfered08_A can't be safely imported! The module itself isn't safe.
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09.stderr
new file mode 100644 (file)
index 0000000..bb5c926
--- /dev/null
@@ -0,0 +1,6 @@
+[1 of 3] Compiling UnsafeInfered09_B ( UnsafeInfered09_B.hs, UnsafeInfered09_B.o )
+[2 of 3] Compiling UnsafeInfered09_A ( UnsafeInfered09_A.hs, UnsafeInfered09_A.o )
+[3 of 3] Compiling UnsafeInfered09  ( UnsafeInfered09.hs, UnsafeInfered09.o )
+
+UnsafeInfered09.hs:4:1:
+    main:UnsafeInfered09_A can't be safely imported! The module itself isn't safe.
index f6fce3b..5f1e51c 100644 (file)
@@ -1,5 +1,5 @@
-{-# LANGUAGE TemplateHaskell #-}
 {-# LANGUAGE Safe #-}
+{-# LANGUAGE TemplateHaskell #-}
 module Main where
 
 import SafeLang12_A
index 137f3b5..c6d6384 100644 (file)
@@ -2,7 +2,7 @@
 -- | Import unsafe module Foreign.Unsafe to make sure it fails
 module Main where
 
-import Foreign.Unsafe (unsafePerformIO)
+import System.IO.Unsafe (unsafePerformIO)
 
 f :: Int
 f = unsafePerformIO $ putStrLn "What kind of swallow?" >> return 2
index ea2b640..da0f440 100644 (file)
@@ -5,7 +5,7 @@ module Main where
 import Unsafe.Coerce
 
 f :: Int
-f = trace "What kind of swallow?" 2
+f = 2
 
 main :: IO ()
 main = putStrLn $ "X is: " ++ show f
index 0df948e..18c50df 100644 (file)
@@ -2,10 +2,10 @@
 -- | Import unsafe module Control.ST to make sure it fails
 module Main where
 
-import Control.ST
+import Control.Monad.ST
 
 f :: Int
-f = trace "What kind of swallow?" 2
+f = 2
 
 main :: IO ()
 main = putStrLn $ "X is: " ++ show f
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/GoodImport03.stderr b/testsuite/tests/safeHaskell/unsafeLibs/GoodImport03.stderr
new file mode 100644 (file)
index 0000000..33d90f9
--- /dev/null
@@ -0,0 +1,4 @@
+
+GoodImport03.hs:25:1:
+    Warning: Module `Control.OldException' is deprecated:
+               Future versions of base will not support the old exceptions style. Please switch to extensible exceptions.