Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
coot authored and Bodigrim committed Jul 29, 2023
1 parent 7cb61b6 commit 8043c0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions core/Test/Tasty/Ingredients/ConsoleReporter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ import Data.Foldable (foldMap)
-- @since 0.12
data TestOutput
= PrintTest
{- test name -} String
{- print test name -} (IO ())
{- test name -} String
{- print test name -} (IO ())
{- print test progress -} (Progress -> IO ())
{- print test result -} (Result -> IO ())
{- print test result -} (Result -> IO ())
-- ^ Name of a test, an action that prints the test name, and an action
-- that renders the result of the action.
--
Expand Down Expand Up @@ -270,7 +270,8 @@ consoleOutput toutput smap =
, Any True)
foldHeading _name printHeading (printBody, Any nonempty) =
( Traversal $ do
when nonempty $ do printHeading :: IO (); getTraversal printBody
when nonempty $ printHeading
getTraversal printBody

This comment has been minimized.

Copy link
@andreasabel

andreasabel Oct 20, 2023

Collaborator

@coot This commit is labelled "clean code", but the change performed here is a priori a semantic change.
getTraversal printBody is now executed even when nonempty is False.

(Reminds me of the "heartbleed" bug: https://dwheeler.com/essays/apple-goto-fail.html)

This comment has been minimized.

Copy link
@coot

coot Oct 21, 2023

Author Contributor

That's probably a bug. I didn't mean to change the semantics.

, Any nonempty
)

Expand Down
2 changes: 1 addition & 1 deletion core/Test/Tasty/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ executeTest
-> Seq Finalizer -- ^ finalizers (to be executed in this order)
-> IO ()
executeTest action statusVar timeoutOpt inits fins = mask $ \restore -> do
resultOrExn <- try $ restore $ do
resultOrExn <- try . restore $ do
-- N.B. this can (re-)throw an exception. It's okay. By design, the
-- actual test will not be run, then. We still run all the
-- finalizers.
Expand Down

0 comments on commit 8043c0c

Please sign in to comment.