runWithWatchdog_ :: (HasCallStack, MonadBaseControl IO m)=> WatchdogConfigconfiguration
-> (HasCallStack => m a)a test case to be wrapped in watchdog
-> m a
Execute a test case with a watchdog.
:: a typeCtrl KGHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12
Modulehedgehog-extras-0.10.1.0Haskell2010
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
runWithWatchdog_ :: (HasCallStack, MonadBaseControl IO m)=> WatchdogConfigconfiguration
-> (HasCallStack => m a)a test case to be wrapped in watchdog
-> m aExecute a test case with a watchdog.
runWithWatchdog :: (HasCallStack, MonadBaseControl IO m)=> WatchdogConfigconfiguration
-> (HasCallStack => Watchdog -> m a)a test case to be wrapped in watchdog
-> m aExecute a test case with a watchdog.
runWithDefaultWatchdog_ :: (HasCallStack, MonadBaseControl IO m)=> (HasCallStack => m a)a test case to be wrapped in watchdog
-> m aExecute a test case with watchdog with default config.
runWithDefaultWatchdog :: (HasCallStack, MonadBaseControl IO m)=> (HasCallStack => Watchdog -> m a)a test case to be wrapped in watchdog
-> m aExecute a test case with watchdog with default config.
Enqueue a kick for the watchdog. It will extend the timeout by another one defined in the watchdog configuration.
Enqueue a poison pill for the watchdog. It will stop the watchdog after all timeouts.
A watchdog instance. See the module header for more detailed description.
Configuration for the watchdog.
WatchdogConfigwatchdogTimeout :: IntTimeout in seconds after which watchdog will kill the test case
An exception thrown to the test case thread.
Show WatchdogExceptionDefined in hedgehog-extras-0.10.1.0 · Hedgehog.Extras.Test.TestWatchdogException WatchdogExceptionDefined in hedgehog-extras-0.10.1.0 · Hedgehog.Extras.Test.TestWatchdogThere is also a lower-level API available, giving the ability to provide target thread ID, which watchdog will try to kill.
makeWatchdog :: MonadBase IO m=> WatchdogConfig-> ThreadIdthread id which will get killed after all kicks expire
-> m WatchdogCreate 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).
Run watchdog in a loop in the current thread. Usually this function should be used with withAsync to run it in the background.