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

Add option for printing the number of QuickCheck tests and shrinks #431

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jorisdral
Copy link

Currently, tasty and tasty-quickcheck will print a progress percentage, so one can see test progression. However, once a property finds a failure and starts shrinking, then test progression stops. Importantly, it is not clear how the shrinker is progressing, though it would be useful information to show, e.g., to judge whether a test is shrinking too slow, whether the shrinker loops, or whether a shrunk test case hangs. This commit adds a new option to enable printing the number of QuickCheck tests (and shrinks on test failure) in addition to the percentage.

I know this feature has been suggested before here: #419 (comment)). In my opinion it would be a generally useful feature to include, and it's optional so that it does not use up too much UI space by default. Let me know what you think!

@Bodigrim
Copy link
Collaborator

@jorisdral I'm keen to avoid adding more command-line options. The interface is already quite cluttered.

I'd prefer the following behaviour to be implemented unconditionally: firstly show progress from 0% to 100% while testing (progressText is empty, progressFloat is non-zero), then show number of shrinks (progressText is "XX shrink", progressFloat is zero).

@Bodigrim
Copy link
Collaborator

@jorisdral what do you think about my suggestion above?

No promises, but we might be making a release soon; it would be great if this improvement lands before that.

@jorisdral
Copy link
Author

@Bodigrim I think your suggestion makes sense. I'll see if I can adjust the PR soon

Currently, `tasty` and `tasty-quickcheck` will print a progress percentage, so
one can see test progression. However, once a property finds a failure and
starts shrinking, then test progression stops. Importantly, it is not clear how
the shrinker is progressing, though it would be useful information to show,
e.g., to judge whether a test is shrinking too slow, whether the shrinker loops,
or whether a shrunk test case hangs. This commit changes the progress bar to
print the number of shrinks in case of test failures. Succesful tests will still
print the progress percentage.
@jorisdral
Copy link
Author

@Bodigrim I've updated the PR. Let me know if this is what you had in mind


-- Based on 'QuickCheck.Test.failureSummaryAndReason'.
showShrinkCount :: QC.State -> Bool -> String
showShrinkCount st full = count
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just showShrinkCount st full = concat [...]?

count =
concat [
show (QC.numSuccessShrinks st) ++
concat [ "." ++ show (QC.numTryShrinks st) | showNumTryShrinks ] ++
Copy link
Collaborator

Choose a reason for hiding this comment

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

I spent quite some time deciphering that concat [ xs | c ] is a fancy way to say if c then xs else "". Could we please use the latter form?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The intermediate output seems to be something like 2.1 shrinks. What is it supposed to mean?

I understand that you adapted QuickCheck.Test.failureSummaryAndReason, which has the same cryptic behavior. Could we just show (QC.numSuccessShrinks st) ++ " shrink" ++ (if ... then "" else "s")?

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.

2 participants