Skip to content

Commit

Permalink
Add watchdog for watchdogs
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Apr 30, 2024
1 parent c2f3863 commit 905d792
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Hedgehog/Extras/Test/File.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module Hedgehog.Extras.Test.File

, appendFileTimeDelta
, assertDirectoryMissing
, assertDirectoryExists
) where

import Control.Applicative (Applicative (..))
Expand Down
6 changes: 3 additions & 3 deletions src/Hedgehog/Extras/Test/TestWatchdog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ runWithWatchdog config testCase = do
-- | Execute a test case with a watchdog.
runWithWatchdog_ :: HasCallStack
=> MonadBaseControl IO m
=> WatchdogConfig -- ^ configuration
-> (HasCallStack => m a) -- ^ a test case to be wrapped in watchdog
-> m a
=> WatchdogConfig -- ^ configuration
-> (HasCallStack => m a) -- ^ a test case to be wrapped in watchdog
-> m a
runWithWatchdog_ config testCase = runWithWatchdog config (const testCase)

-- | Execute a test case with watchdog with default config.
Expand Down
4 changes: 2 additions & 2 deletions test/Hedgehog/Extras/Test/TestWatchdogSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import qualified System.Process as P

-- | Check that watchdog kills test case which waits without an end
hprop_check_watchdog_kills_hanged_thread :: Property
hprop_check_watchdog_kills_hanged_thread = H.propertyOnce $ do
hprop_check_watchdog_kills_hanged_thread = H.propertyOnce $ runWithWatchdog_ (WatchdogConfig 5) $ do
let watchdogCfg = WatchdogConfig 1
childTid <- H.newEmptyMVar
tripwire <- H.makeTripwire
Expand All @@ -46,7 +46,7 @@ hprop_check_watchdog_kills_hanged_thread = H.propertyOnce $ do
-- - a process waiting forever
-- - a child threads waiting
hprop_check_watchdog_kills_hanged_thread_with_its_children :: Property
hprop_check_watchdog_kills_hanged_thread_with_its_children = H.propertyOnce $ do
hprop_check_watchdog_kills_hanged_thread_with_its_children = H.propertyOnce $ runWithWatchdog_ (WatchdogConfig 5) $ do
let watchdogCfg = WatchdogConfig 1
childTid <- H.newEmptyMVar
grandChildTid1 <- H.newEmptyMVar
Expand Down
3 changes: 2 additions & 1 deletion test/hedgehog-extras-test.hs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --hide-successes #-}
{-# OPTIONS_GHC -F -pgmF tasty-discover #-}
-- -optF --hide-successes

0 comments on commit 905d792

Please sign in to comment.