Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides a test watchdog - an utility monitoring test cases and killing them if they don't
finish in time. Watchdog
thread runs in the background, and after specified timeout, it throws
WatchdogException
to the target thread. A user is able to kickWatchdog
, which delays the killing and
poisonWatchdog
which stops the watchdog.
To wrap a test case in a watchdog just use
runWithWatchdog watchdogConfig $ \watchdog -> do -- body of your test case
Synopsis
- runWithWatchdog_ :: HasCallStack => MonadBaseControl IO m => WatchdogConfig -> (HasCallStack => m a) -> m a
- runWithWatchdog :: HasCallStack => MonadBaseControl IO m => WatchdogConfig -> (HasCallStack => Watchdog -> m a) -> m a
- runWithDefaultWatchdog_ :: HasCallStack => MonadBaseControl IO m => (HasCallStack => m a) -> m a
- runWithDefaultWatchdog :: HasCallStack => MonadBaseControl IO m => (HasCallStack => Watchdog -> m a) -> m a
- kickWatchdog :: MonadIO m => Watchdog -> m ()
- poisonWatchdog :: MonadIO m => Watchdog -> m ()
- data Watchdog
- newtype WatchdogConfig = WatchdogConfig {}
- newtype WatchdogException = WatchdogException {}
- makeWatchdog :: MonadBase IO m => WatchdogConfig -> ThreadId -> m Watchdog
- runWatchdog :: MonadBase IO m => Watchdog -> m ()
Wrap in watchdog
:: HasCallStack | |
=> MonadBaseControl IO m | |
=> WatchdogConfig | configuration |
-> (HasCallStack => m a) | a test case to be wrapped in watchdog |
-> m a |
Execute a test case with a watchdog.
:: HasCallStack | |
=> MonadBaseControl IO m | |
=> WatchdogConfig | configuration |
-> (HasCallStack => Watchdog -> m a) | a test case to be wrapped in watchdog |
-> m a |
Execute a test case with a watchdog.
runWithDefaultWatchdog_ Source #
:: HasCallStack | |
=> MonadBaseControl IO m | |
=> (HasCallStack => m a) | a test case to be wrapped in watchdog |
-> m a |
Execute a test case with watchdog with default config.
runWithDefaultWatchdog Source #
:: HasCallStack | |
=> MonadBaseControl IO m | |
=> (HasCallStack => Watchdog -> m a) | a test case to be wrapped in watchdog |
-> m a |
Execute a test case with watchdog with default config.
Watchdog control
kickWatchdog :: MonadIO m => Watchdog -> m () Source #
Enqueue a kick for the watchdog. It will extend the timeout by another one defined in the watchdog configuration.
poisonWatchdog :: MonadIO m => Watchdog -> m () Source #
Enqueue a poison pill for the watchdog. It will stop the watchdog after all timeouts.
Types
A watchdog instance. See the module header for more detailed description.
newtype WatchdogConfig Source #
Configuration for the watchdog.
WatchdogConfig | |
|
newtype WatchdogException Source #
An exception thrown to the test case thread.
Instances
Exception WatchdogException Source # | |
Show WatchdogException Source # | |
Defined in Hedgehog.Extras.Test.TestWatchdog showsPrec :: Int -> WatchdogException -> ShowS # show :: WatchdogException -> String # showList :: [WatchdogException] -> ShowS # |
Low level API
There is also a lower-level API available, giving the ability to provide target thread ID, which watchdog will try to kill.
:: MonadBase IO m | |
=> WatchdogConfig | |
-> ThreadId | thread id which will get killed after all kicks expire |
-> m Watchdog |
Create manually a new watchdog, providing the target thread ID. After all watchdog timeouts expire,
the target thread will get WatchdogException
thrown to it asynchronously (using throwTo
).