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

Fail property test when discard count exceeds maximumDiscarded #112

Merged
merged 3 commits into from
Nov 8, 2024

Conversation

zainab-ali
Copy link
Contributor

Property tests with a maximumDiscarded value of zero fail without running any tests. This is a bug introduced by the stream refactors in #39.

This is because the status stream now outputs an initial empty Status.start value which satisfies the discard <= maximumDiscarded stop condition.

Prior to the refactor, the stream wouldn't output the Status.start value, so a single test would be run before the condition was checked. This behaviour was also odd: even if no values were actually discarded, the property test could fail with a discard error.

This PR alters the discard behaviour. The discard count must exceed the maximumDiscarded value, not be equal to it. This means that if a maximumDiscarded value of 0 is set, then the test will fail if 1 value is discarded.

dogfood.runSuite(Meta.ConfigOverrideChecks))
}

test("Discarded counts should be accurate") { dogfood =>
expectErrorMessage(
s"Discarded more inputs (${Meta.DiscardedChecks.checkConfig.maximumDiscarded}) than allowed",
s"Discarded more inputs (${Meta.DiscardedChecks.checkConfig.maximumDiscarded + 1}) than allowed",
Copy link

Choose a reason for hiding this comment

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

I'd be surprised to see a number different than what's in the config. How about a slightly redacted message?

Suggested change
s"Discarded more inputs (${Meta.DiscardedChecks.checkConfig.maximumDiscarded + 1}) than allowed",
s"Discarded more inputs than allowed. Input discard limit is ${Meta.DiscardedChecks.checkConfig.maximumDiscarded}.",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely! I've gone with the slightly more terse:

Discarded more inputs (2) than allowed (1)

@zainab-ali zainab-ali merged commit a71c932 into typelevel:main Nov 8, 2024
13 checks passed
@zainab-ali zainab-ali deleted the fix-scalacheck-config branch November 8, 2024 11:24
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.

3 participants