hedgehog-extras-0.6.3.0: Supplemental library for hedgehog
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hedgehog.Extras.Test.TestWatchdog

Description

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

Wrap in watchdog

runWithWatchdog_ Source #

Arguments

:: 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.

runWithWatchdog Source #

Arguments

:: 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 #

Arguments

:: 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 #

Arguments

:: 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

data Watchdog Source #

A watchdog instance. See the module header for more detailed description.

Instances

Instances details
Show Watchdog Source # 
Instance details

Defined in Hedgehog.Extras.Test.TestWatchdog

newtype WatchdogConfig Source #

Configuration for the watchdog.

Constructors

WatchdogConfig 

Fields

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.

makeWatchdog Source #

Arguments

:: 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).

runWatchdog :: MonadBase IO m => Watchdog -> m () Source #

Run watchdog in a loop in the current thread. Usually this function should be used with withAsync to run it in the background.