Use assert{Bool,Failure} from tasty-hunit #1065
Merged
+6
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use
assert{Bool,Failure}
fromtasty-hunit
rather thanhunit
. Gives better error printing.Before:
After:
Background
Following the discussion at UnkindPartition/tasty#327 (comment) :
@andreasabel wrote:
There is a
Show
instance forHUnitFailure
which gives the Haskell representation of this exception. So far so good.I am looking for a function that pretty-prints the exception, for presentation to the user.
It should look nicer than what
Show
gives me:@VictorCMiraldo wrote:
I started working on this today but I couldn't reproduce the problem. Eventually I discovered that @andreasabel and I did something wrong. What we did is some variation on:
The issue comes from the fact that
Raw.HUnitAssertion
is a different type altogether fromTasty.HUnitAssertion
. BecauseTasty.Assertion == Raw.Assertion == IO ()
, and failures are communicated through exceptions, we're bypassing thetry
onTasty.HUnit.run
and flagging the test as failed through a random exception, since that method istry
ing onTasty.HUnitAssertion
.The solution is to not depend on
HUnit
, depend exclusively ontasty-hunit
and use the functions from there. Your test failures will be printed properly then.