tasty-process-0.1.0.1: Test execution of external processes with Tasty
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Tasty.Process

Synopsis

Documentation

processTest :: TestName -> TestProcess -> TestTree Source #

Create a TestTree from a TestProcess. Here is an example of how to use the function to create a test.

exampleTest :: TestTree
exampleTest =
  setTimeout (1000000) $
    processTest
      "Simple test"
      TestProcess
        { process =
          (proc "test-executable-simple" [])
        , input = Nothing
        , exitCodeCheck = equals ExitSuccess
        , stdoutCheck = equals "Hello, world!n"
        , stderrCheck = equals ""
        }

data TestProcess Source #

TestProcess is a data type that represents a process to be tested.

Constructors

TestProcess 

Fields

proc :: FilePath -> [String] -> CreateProcess Source #

Re-export of proc from System.Process with correct default values.

Construct a CreateProcess record for passing to createProcess, representing a command to be passed to the shell.

shell :: String -> CreateProcess Source #

Re-export of shell from System.Process with correct default values.

Construct a CreateProcess record for passing to createProcess, representing a raw command with arguments. See RawCommand for precise semantics of the specified FilePath.

defaultProcess :: TestProcess Source #

The template process configuration.

type ExitCodeCheck = ExitCode -> Either String () Source #

ExitCodeCheck represents a function that given the ExitCode of a process, returns () if the exit code is expected, or a reason otherwise.

type OutputCheck = String -> Either String () Source #

OutputCheck represents a function that given the output of a process, returns () if the output is expected, or a reason otherwise.

equals :: (Show a, Eq a) => a -> a -> Either String () Source #

A helper function for creating equality checks.

>>> equals "str" "str"
Right ()
>>> equals ExitSuccess ExitSuccess
Right ()
>>> equals "expected value" "actual value"
Left "expected : \"expected value\"\nactual   : \"actual value\"\n"

ignored :: a -> Either String () Source #

A helper function to ignore checks.

>>> ignored "any value"
Right ()

setTimeout :: Integer -> TestTree -> TestTree Source #

Set the timeout (in microseconds) for a TestTree.