Skip to content

Commit

Permalink
Force the result description within the timeout. Fixes #280
Browse files Browse the repository at this point in the history
  • Loading branch information
UnkindPartition committed Oct 25, 2020
1 parent 9679520 commit fcfccc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions core/Test/Tasty/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Test.Tasty.Patterns.Types
import Test.Tasty.Options
import Test.Tasty.Options.Core
import Test.Tasty.Runners.Reducers
import Test.Tasty.Runners.Utils (timed)
import Test.Tasty.Runners.Utils (timed, forceElements)
import Test.Tasty.Providers.ConsoleFormat (noResultDetails)

-- | Current status of a test
Expand Down Expand Up @@ -106,7 +106,15 @@ executeTest action statusVar timeoutOpt inits fins = mask $ \restore -> do
-- handler doesn't interfere with our timeout.
withAsync (action yieldProgress) $ \asy -> do
labelThread (asyncThreadId asy) "tasty_test_execution_thread"
timed $ applyTimeout timeoutOpt $ wait asy
timed $ applyTimeout timeoutOpt $ do
r <- wait asy
-- Not only wait for the result to be returned, but make sure to
-- evalute it inside applyTimeout; see #280.
evaluate $
resultOutcome r `seq`
forceElements (resultDescription r) `seq`
forceElements (resultShortDescription r)
return r

-- no matter what, try to run each finalizer
mbExn <- destroyResources restore
Expand Down
3 changes: 2 additions & 1 deletion core/Test/Tasty/Runners/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ formatMessage = go 3
Right () -> return msg
Left e' -> printf "message threw an exception: %s" <$> go (recLimit-1) (show (e' :: SomeException))

-- https://ro-che.info/articles/2015-05-28-force-list
-- | Force elements of a list
-- (<https://ro-che.info/articles/2015-05-28-force-list>)
forceElements :: [a] -> ()
forceElements = foldr seq ()

Expand Down

0 comments on commit fcfccc8

Please sign in to comment.