Safe Haskell | Safe-Infered |
---|
Helpers for asserting certain things for programs, using HUnit.
All of the assertions in this module throw HUnit exceptions on failure
using assertFailure
.
- runAssert :: Timeout -> FilePath -> [String] -> IO (Handle, Handle, Handle, ProcessHandle)
- assertExited :: ProcessHandle -> IO ()
- _PROCTEST_POLL_TIMEOUT :: Timeout
- assertExitedTimeout :: Timeout -> ProcessHandle -> IO ExitCode
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 sleep
ing:
For most tests, the application will actually finish way before the timeout.
If the process is still running, a HUnit assertFailure
exception is thrown.