-
Notifications
You must be signed in to change notification settings - Fork 110
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
Avoid running earlier successes with --quickcheck-replay #410
Avoid running earlier successes with --quickcheck-replay #410
Conversation
475d8e9
to
14e6ce9
Compare
14e6ce9
to
1f6ed71
Compare
quickcheck/Test/Tasty/QuickCheck.hs
Outdated
in printf "Use --quickcheck-replay=%d%s to reproduce." seed sizeStr | ||
makeReplayMsg :: (QCGen, Int) -> String | ||
makeReplayMsg seedSz = | ||
printf "Use --quickcheck-single-replay=\"%s\" to reproduce." (show seedSz) |
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.
Probably we should display both the value of --quickcheck-replay
and --quickcheck-single-replay
here. Otherwise, the user of --quickcheck-replay
has no way to get a seed.
The value printed for --quickcheck-replay
would be only meaningful when not setting --quickcheck-single-replay
. Otherwise, the result of the run is unrelated to the value of --quickcheck-replay
.
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.
What are the remaining use cases for --quickcheck-replay
now? I guess you can just reuse it without introducing a new command line flag.
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 don't know who is relying on the old behavior. I'm happy to break that if nobody cares.
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 find it hard to imagine that someone would consciously prefer old behaviour to a new, but it seems you can support both without too much trouble. If it's --quickcheck-replay=(QCGen ..., 42)
do a new thing, if it's --quichckeck-replay=QCGen...
do the old thing.
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.
And when printing, should we show both forms when sensible?
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.
Showing one form would be enough IMO.
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.
It can be done as you suggest. But note that the old form is unusable if the user has no way to discover the seeds that go with it. What would be the purpose of supporting the old form as input then?
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.
Just an escape hatch. I do not see why a user might want the old behavior back; but someone could have a regression script still using an old format. Not crashing in such scenario would be useful.
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.
Pushed. Also added a note to the change log. Thanks for your review @Bodigrim!
b87ef3a
to
f5206e2
Compare
On failure, tasty-quickcheck now suggests string seeds (no integer seeds anymore). Integer seeds are still accepted as input though.
f5206e2
to
363da1a
Compare
I was wondering, is this PR good to merge? Or does it need more reviews? |
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.
A few more wibbles, but overall looks good to me, thanks!
CC @andreasabel @martijnbastiaan @VictorCMiraldo to review.
quickcheck/Test/Tasty/QuickCheck.hs
Outdated
-- | Replay seed. The @Left int@ form is kept for legacy purposes. | ||
-- The form @Right (qcgen, intSize)@ holds both the seed and the size | ||
-- to run QuickCheck tests. | ||
newtype QuickCheckReplay = QuickCheckReplay (Maybe (Either Int (QCGen, Int))) |
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.
Could it be
newtype QuickCheckReplay = QuickCheckReplay (Maybe (Either Int (QCGen, Int))) | |
newtype QuickCheckReplay = QuickCheckReplay (Maybe (Int, Maybe QCGen)) |
?
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 find the code easier to approach as it is.
-
The two Ints in the Either type have different meanings, whether the meaning of the Int in the Maybe form depends on the value of the second component of the pair.
-
The quickcheck API can take the pair
(QCGen, Int)
as is without further ado.
But let me know if you still think the Maybe
form is to be preferred.
Another option is to use a custom type:
data Seed = OldSeed Int | NewSeed (QCGen, Int)
or
data QuickcheckReplay = QuickcheckReplay Int | QuickcheckReplayNew (QCGen, Int)
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.
OK, unless someone else feels strongly about it, I'm fine to keep it as is.
Co-authored-by: ˌbodʲɪˈɡrʲim <[email protected]>
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.
LGTM.
I do like a custom data type better (Seed
/QuickCheckReplay
), but I'm fine with keeping it as it is now too.
Thanks @martijnbastiaan
I contributed an implementation of this idea in facundominguez#1. |
This looks nice. Please add it to this PR + mention the change to |
|
921dc11
to
7dc69b6
Compare
I added |
@facundominguez thanks! @amesgen as an original author of #383, are you happy with this solution? |
I'm a bit embarrassed to admit that I cannot discover on my own what needs updating there. 🙈 |
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.
This looks excellent!
@facundominguez the output of Thanks for your contribution, merging. |
From the [changelog](https://hackage.haskell.org/package/tasty-quickcheck-0.11/changelog): > Produce seeds that run a single failing tests instead of reproducing all the earlier successes ([#410](UnkindPartition/tasty#410)). > > Seeds are now pairs instead of single integers, e.g. `--quickcheck-replay="(SMGen 2909028190965759779 12330386376379709109,0)"` > > Single integer seeds are still accepted as input, but they do run through earlier successes. > > The `QuickCheckReplay` type used as a tasty option has three data constructors now. `QuickCheckReplayNone` is the default value and provides no seed. `QuickCheckReplayLegacy` takes an integer as before. The `QuickCheckReplay` data constructor takes the new seed form. This is very useful both for slow tests, as well as for the WIP nightly tests.
Version 0.11.1 -------------- * Add timeouts for individual tests within a property ([#425](UnkindPartition/tasty#425)). * Define `showDefaultValue` for `QuickCheckTests`, `QuickCheckMaxSize` and `QuickCheckMaxRatio` ([#428](UnkindPartition/tasty#428)). * Print the number of QuickCheck shrinks in the progress message ([#431](UnkindPartition/tasty#431)). * Drop support for GHC 7.10. Version 0.11 -------------- * Fix issues with QuickCheck progress reporting in the presence of `withMaxSuccess` ([#419](UnkindPartition/tasty#419)). * Produce seeds that run a single failing tests instead of reproducing all the earlier successes ([#410](UnkindPartition/tasty#410)). Seeds are now pairs instead of single integers, e.g. `--quickcheck-replay="(SMGen 2909028190965759779 12330386376379709109,0)"` Single integer seeds are still accepted as input, but they do run through earlier successes. The `QuickCheckReplay` type used as a tasty option has three data constructors now. `QuickCheckReplayNone` is the default value and provides no seed. `QuickCheckReplayLegacy` takes an integer as before. The `QuickCheckReplay` data constructor takes the new seed form.
On failure, tasty-quickcheck now suggests string seeds (with an implementation-dependent structure). Integer seeds are still accepted as input though.
Fixes #383