-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --fail-fast
#455
Add --fail-fast
#455
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please try the following: Add a test case with a failing $setup
and run it with --fail-fast
, then observe if it will abort early. My suspicion is no, it won't.
To address this you may need to add shortcut semantics to the stack (e.g. add MaybeT
to the Report
type).
Ideally this will allow you to handle early abortion in reportFailure
/ reportError
.
Regarding the failing CI job, you'll need to run |
@tgdwyer just to be sure, because the tests take a long time to run, you can focus on individual test cases by changing https://hackage.haskell.org/package/hspec-2.11.9/docs/Test-Hspec.html#g:5 |
I have renamed the option to --fail-fast and made the various merges and cleanups. I did some experimenting with $setup and it looks like it fast fails already. For the following test: module Foo where
-- $setup
-- >>> let x = 1 + "hello"
-- | foo
-- >>> foo
-- 42
foo :: Int
foo = 42 doctest (whether with --fast-fail or not) produces:
Meanwhile, I agree it would probably better to use MaybeT to respond to fast fail than just looking for failures in the Report counts. I would like to investigate this, but won't have time for a few weeks. Any such refactoring would probably need to be part of a separate PR. Anything else? |
I think what's happening here is that, if I somehow missed that on my first review. |
I've changed the logic of runModule to skip if failures > 0 (rather than only on increasing failure count). Thus, after the first failure all subsequent examples will be skipped regardless of module. I've also run hpack so the test files are included in doctest.cabal and the CI should run. |
I think I've implemented all the requested changes and that it's ready for merge, if you're happy? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still not working correctly if you have multiple $setup
blocks (see my other comment).
Would you mind cherry-picking bbe00c6 and using this as a starting point?
@tgdwyer also cherry-pick b4a777c, or just rebase on https:/sol/doctest/tree/maybe-t. |
Done! Thanks for wrapping Report in MaybeT! FailFast logic is much better now. Latest commits just use forM_ to traverse the Maybe effect in runModule, same as runModules. Code is much cleaner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, the code looks good now 👍
Let's clean up the test descriptions, and then it's good to go.
In addition, I think you need to run hpack again.
Added a command line option "--stop-on-fail".
When in --stop-on-fail mode, after a test in an example group fails, running tests from subsequent example groups is aborted.