Safe Haskell | None |
---|---|
Language | Haskell2010 |
In this module there are functions for creating test cases that run programs. It also provides functions for running programs that require input.
- data Stream
- type Driver = Free DriverF
- runDriver :: Int -> (Handle, Handle, Handle) -> Driver a -> HClTest String a
- expect :: Stream -> Text -> Driver ()
- expectEOF :: Stream -> Driver ()
- send :: Text -> Driver ()
- testInteractive :: Maybe FilePath -> Maybe [(String, String)] -> Int -> FilePath -> [String] -> Driver ExitCode -> HClTest Trace ()
- testStdout :: Maybe FilePath -> Maybe [(String, String)] -> Int -> FilePath -> [String] -> ExitCode -> Text -> HClTest Trace ()
- testExitCode :: Maybe FilePath -> Maybe [(String, String)] -> Int -> FilePath -> [String] -> ExitCode -> HClTest Trace ()
Documentation
type Driver = Free DriverF Source
The driver monad. The driver monad is used to run programs that require input. It allows you to specify a "script" of actions, like "send input" or "expect output".
runDriver :: Int -> (Handle, Handle, Handle) -> Driver a -> HClTest String a Source
Run a driver. The first argument is the timeout for waiting for output of the process. The second argument are handles to stdin, stdout and stderr of the process. The third argument is the driver to run. This produces a test step.
expect :: Stream -> Text -> Driver () Source
Check that the process outputs the given text on the given output stream. This only matches a prefix, so it also succeeds if the process produces more output. If you want to check that this is the only output, use expectEOF.
testInteractive :: Maybe FilePath -> Maybe [(String, String)] -> Int -> FilePath -> [String] -> Driver ExitCode -> HClTest Trace () Source
Make a test step for an interactive program. The first argument is either the working directory or Nothing, which doesn't change the working directory. The second argument is the timeout in seconds for waiting for output of the process. The third argument is the executable file. The forth argument are the arguments for the executable and the fifth is the driver to use. The driver should return the expected exit code.
testStdout :: Maybe FilePath -> Maybe [(String, String)] -> Int -> FilePath -> [String] -> ExitCode -> Text -> HClTest Trace () Source
A restricted form of testInteractive that Only tests that the process produces the given output on stderr, and no more. See
testInteractive
for a description of the arguments.