hcltest-0.3.8: A testing library for command line applications.

Safe HaskellNone
LanguageHaskell2010

Test.HClTest.Program

Description

In this module there are functions for creating test cases that run programs. It also provides functions for running programs that require input.

Synopsis

Documentation

data Stream Source

A output stream.

Constructors

Stdout 
Stderr 

Instances

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.

expectEOF :: Stream -> Driver () Source

Check that the process' output ended.

send :: Text -> Driver () Source

Send some text to the process. The text will be encoded as UTF-8.

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.

testExitCode :: Maybe FilePath -> Maybe [(String, String)] -> Int -> FilePath -> [String] -> ExitCode -> HClTest Trace () Source

A restricted form of testInteractive that only tests that the process exits with the given exit code. See testInteractive for a description of the arguments.