proctest-0.1.3.0: An IO library for testing interactive command line programs

Safe HaskellSafe-Infered

Test.Proctest.Assertions

Contents

Description

Helpers for asserting certain things for programs, using HUnit.

All of the assertions in this module throw HUnit exceptions on failure using assertFailure.

Synopsis

Starting programs

runAssert :: Timeout -> FilePath -> [String] -> IO (Handle, Handle, Handle, ProcessHandle)Source

Runs the given program with run and asserts that it is still running after the given timeout.

Don't choose the timeout too high as this function will block for it.

If the timeout is exceeded, a HUnit assertFailure exception is thrown, showing the command line to be invoked, the exit code, and the standard error output of the program.

assertExited :: ProcessHandle -> IO ()Source

Asserts that the given process has shut down.

You might need to sleep before to give the process time to exit. It is usually better to use assertExitedTimeout in those cases.

If the process is still running, a HUnit assertFailure exception is thrown.

_PROCTEST_POLL_TIMEOUT :: TimeoutSource

How often to poll in waiting functions with maximum timeout.

assertExitedTimeout :: Timeout -> ProcessHandle -> IO ExitCodeSource

Asserts that the given process has shut down in *at most* the given timeout.

Periodically polling with _PROCTEST_POLL_TIMEOUT, returns as soon as the application has terminated or the timeout is exceeded.

Use this to write faster tests than with manual sleeping: For most tests, the application will actually finish way before the timeout.

If the process is still running, a HUnit assertFailure exception is thrown.