| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Test.Main
Contents
- captureProcessResult :: IO () -> IO ProcessResult
- data ProcessResult = ProcessResult {
- prStdout :: !ByteString
- prStderr :: !ByteString
- prExitCode :: !ExitCode
- withStdin :: ByteString -> IO a -> IO a
- withArgs :: [String] -> IO a -> IO a
- data ExitCode :: * = ExitSuccess
Utilities for testing your main function
captureProcessResult :: IO () -> IO ProcessResult Source #
Capture stdout, stderr, and exit code of the given IO action.
>>>let main = putStr "hello">>>captureProcessResult mainProcessResult {prStdout = "hello", prStderr = "", prExitCode = ExitSuccess}
If the IO action exit with error message, the exit code of result is ExitFailure.
>>>import System.IO>>>import System.Exit>>>let main = hPutStr stderr "OMG!" >> exitWith (ExitFailure 1)>>>captureProcessResult mainProcessResult {prStdout = "", prStderr = "OMG!", prExitCode = ExitFailure 1}
data ProcessResult Source #
Used for the result of captureProcessResult.
Constructors
| ProcessResult | |
Fields
| |
Instances
withStdin :: ByteString -> IO a -> IO a Source #
Pass the ByteString to stdin of the given IO action.
>>>import Data.ByteString.Char8 ()>>>:set -XOverloadedStrings>>>let main = putStrLn . reverse =<< getLine>>>withStdin "abcde" mainedcba