Skip to content
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

Fix test skipping when tests have been discarded. #489

Merged

Conversation

ChickenProp
Copy link
Contributor

Closes #487.

In #454 we introduced test skipping, with the idea that a failed test could report a way for you to jump back to reproduce it without all the preceding tests.

But it didn't work if any of the preceding tests had been discarded, because each discard also changes the seed and the size. Users could manually add the discard count to the test count in the Skip, but that's no fun. Plus, it wouldn't work if the test count plus discard count exceeded the test limit, because that would generate a success without running any tests.

So now a Skip (other than SkipNothing) includes a DiscardCount as well as a TestCount. It's rendered in the compressed path as testCount/discardCount, or just testCount if discardCount is 0. The exact sequence of passing tests and discards doesn't affect the final seed or size, so the counts are all we need.

This changes an exposed type, so PVP requires a major version bump.

This is awkward for me personally because it's incompatible with the approach I took in #474, I'll leave a comment there with more details.

@TysonMN
Copy link
Member

TysonMN commented May 25, 2023

Why is it necessary to track testCount and discardCount separately? I was expecting that it would suffice to only track their sum.

@ChickenProp
Copy link
Contributor Author

If we only track the sum, we'd need to handle the case when that's larger than the number of tests we want to run. Which might be fine - I think this is a case where it's not clear exactly what behavior is best. It also means that we'd get a failure "after 3 tests and 7 discards", and then we'd try to reproduce it and get told it failed "after 10 tests", which seems mildly bad.

@TysonMN
Copy link
Member

TysonMN commented May 25, 2023

I think that message is not helpful when recording

@ChickenProp
Copy link
Contributor Author

I agree it's not really helpful, but if it's going to be there it seems kinda confusing if it doesn't match the one they got before. We could remove it when replaying I guess, but that would involve more changes.

Ultimately, it would be possible to only track (sum of tests and discards), but I think tracking them separately is mildly more user friendly and mildly easier to implement.

@ChickenProp
Copy link
Contributor Author

@moodmosaic gentle nudge - it would be good to get this fix in, I think.

Copy link
Member

@moodmosaic moodmosaic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChickenProp, could this break any external integration?

@moodmosaic
Copy link
Member

For the rest of the changes, as also mentioned in #454, it'd be nice also here if our friends can take a look wrt tasty/hspec hedgehog integrations. /cc @parsonsmatt @dalaing @gwils

@gwils
Copy link
Contributor

gwils commented Jul 26, 2023

@moodmosaic This is easy for us to support; I have a patch ready to go. It will be especially easy if you do release this as part of hedgehog 1.4 instead of 1.3.x, since then our upper bounds will work correctly without revision.

@moodmosaic
Copy link
Member

Sure, no problem for 1.4 as it's also more correct.

If that works, we can merge after @ChickenProp resolves the conflicts and then do a hedgehog 1.4 release this weekend. 🦔

@ChickenProp
Copy link
Contributor Author

could this break any external integration?

I might be misinterpreting, but is the question "could this break packages that depend on hedgehog?"

I don't expect downstream users to commit code with a ShrinkPath, so it shouldn't cause problems for them. Packages integrating with hedgehog might need changes. But I think hspec-hedgehog didn't need changes to support v1.2 when we got shrink paths, so I don't expect it to need changes for this; and it sounds like tasty is on top of things.

Closes hedgehogqa#487.

In hedgehogqa#454 we introduced test skipping, with the idea that a failed test
could report a way for you to jump back to reproduce it without all the
preceding tests.

But it didn't work if any of the preceding tests had been discarded,
because each discard also changes the seed and the size. Users could
manually add the discard count to the test count in the `Skip`, but
that's no fun. Plus, it wouldn't work if the test count plus discard
count exceeded the test limit, because that would generate a success
without running any tests.

So now a `Skip` (other than `SkipNothing`) includes a `DiscardCount` as
well as a `TestCount`. It's rendered in the compressed path as
`testCount/discardCount`, or just `testCount` if `discardCount` is 0.
The exact sequence of passing tests and discards doesn't affect the
final seed or size, so the counts are all we need.

This changes an exposed type, so PVP requires a major version bump.
@ChickenProp
Copy link
Contributor Author

Rebased with conflicts fixed.

@moodmosaic moodmosaic merged commit 1475a68 into hedgehogqa:master Aug 1, 2023
21 of 22 checks passed
@moodmosaic
Copy link
Member

Thank you, @ChickenProp 🚀 A hedgehog 1.4 release is planned for this weekend. 🦔

@moodmosaic
Copy link
Member

Release just went out. 🦔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

recheckAt does not always reproduce a test failure
4 participants