Created
May 26, 2015 01:29
-
-
Save thsutton/844401f11d742265dd3e to your computer and use it in GitHub Desktop.
Invoke GHC to check that files compile in a cabal test suite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System.Exit | |
import System.Process | |
main :: IO () | |
main = do | |
(c1, o1, e1) <- readProcessWithExitCode "ghc" ["-ilib", "-o", "/tmp/failure", "test/fail.hs"] "" | |
(c2, o2, e2) <- readProcessWithExitCode "ghc" ["-ilib", "-o", "/tmp/passure", "test/pass.hs"] "" | |
case (c1, c2) of | |
(ExitFailure _, ExitSuccess ) -> exitSuccess | |
(ExitSuccess , ExitSuccess ) -> putStrLn "Fail did not fail" >> exitFailure | |
(ExitSuccess , ExitFailure _) -> putStrLn "Pass did not pass" >> putStrLn "Fail did not fail" >> exitFailure | |
(ExitFailure _, ExitFailure _) -> putStrLn "Pass did not pass" >> exitFailure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment