-
Notifications
You must be signed in to change notification settings - Fork 157
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
regex generation tests same case multiple times #70
Comments
This is an inevitable consequence of the design of proptest's shrinking process. In order to explore another simplification path, the shrinker must first return to a failing test case, which in your example means returning to the original input. It would be possible to redifine the
Indeed. This isn't unique to strings. Shrinking for essentially all types more complex than |
Some context: I am working on a complicated strategy with slow tests associated with it. The current implementation filters out the parts of the generated input that doesn't make sense. This means that shrinking takes a long time (several hours), and that the same input is fed to the tests many times (hundreds). A better strategy may fix this situation (suggestions welcome), but that is the context I am coming from. I wonder whether we could have an opt in setting for the proptest macro that when shrinking would cache the inputs and whether the test passed so when an input is regenerated the test could get skipped. Edit: in my case it is not the regex causing the repeated test behavior. So I intended to suggest this as a more generally applicable fix. |
I ended up writing my own |
I meant to reply earlier that I really like this idea. It's been added in 0.8.6. |
|
Having now looked at a large number of shrink |
I’ve implemented it here:
https://github.com/danburkert/kudu-rs/blob/master/src/prop/string.rs. Feel
free to take that and adapt as necessary. There’s also a version for
binary in another module.
…On Tue, Oct 30, 2018 at 12:56 PM Jacob Finkelman ***@***.***> wrote:
Having now looked at a large number of shrink HashSet<String>, I'd love
to have an alternative steiker that shrinks strings lexicographic, like how
we have bits module
<https://altsysrq.github.io/rustdoc/proptest/latest/proptest/bits/index.html>.
Not that I have any ideas how to implement that.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#70 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJx8osj9ehGDzFf-AIF9KLOiv18egqwks5uqK7_gaJpZM4VC5l0>
.
|
Yes that is a good start, I'd want it to have the regex interfase of the current string generators. |
With the regex pattern
[a-z]{1, 5}
and the assertion that the output length is even,proptest
will repeatedly test the same (original) value over and over as it shrinks/expands:Here's the test for context:
This also demonstrates the shrinking method used by
proptest
can get 'stuck' at a local minimum (in this caseaaaaa
instead ofa
) because it doesn't try shrinking more than one character at once. This seems like a more difficult issue to fix, though. Perhaps there's some literature on effective string shrinking strategies out there?The text was updated successfully, but these errors were encountered: