Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor out failAfter and re-use it between tests
- Loading branch information
Showing
4 changed files
with
39 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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) | ||
|
||
failAfter :: HasCallStack => DiffTime -> IO () -> IO () | ||
failAfter seconds action = | ||
timeout seconds action >>= \case | ||
Nothing -> expectationFailure $ "Test timed out after " <> show seconds <> " seconds" | ||
Just _ -> pure () |