Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use io-sim-classes to replace IO with IOSim later
Also, 'expectationFailure' got replaced by 'error' (for now). Maybe use 'MonadThrow' instead?
- Loading branch information
Showing
5 changed files
with
64 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
module Test.Util where | ||
|
||
import Cardano.Prelude | ||
import Control.Monad.Class.MonadTime (DiffTime) | ||
import Control.Monad.Class.MonadTimer (timeout) | ||
import Test.Hspec (expectationFailure) | ||
import Control.Monad.Class.MonadTimer (DiffTime, MonadTimer, timeout) | ||
import Prelude (error) | ||
|
||
failAfter :: HasCallStack => DiffTime -> IO () -> IO () | ||
failAfter :: (HasCallStack, MonadTimer m) => DiffTime -> m () -> m () | ||
failAfter seconds action = | ||
timeout seconds action >>= \case | ||
Nothing -> expectationFailure $ "Test timed out after " <> show seconds <> " seconds" | ||
-- TODO(SN): use MonadThrow instead? | ||
Nothing -> error $ "Test timed out after " <> show seconds <> " seconds" | ||
Just _ -> pure () |