module Main (main)
where
import Language.C.Test.Framework
import System.Environment (getArgs)
import System.IO (hPutStrLn, stderr)
import System.Exit (exitWith,ExitCode(..))
bail :: String -> IO a
bail msg = hPutStrLn stderr msg >> exitWith (ExitFailure 1) >> error "<unreachable>"
usage :: String
usage = "ReportFatal report-file.dat arg_1 [ ... arg_n ] < error-log"
main :: IO ()
main = do
arguments <- getArgs
(reportFile,testargs) <-
case arguments of
(rf:args@(_:_)) -> do
return (rf,args)
_ -> bail usage
errMsg <- getContents
appendFile reportFile $ show FatalError { fatalErrMsg = errMsg, runArgs = testargs } ++ "\n"