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

Test database a la Hypothesis? #50

Open
mwotton opened this issue May 17, 2023 · 3 comments
Open

Test database a la Hypothesis? #50

mwotton opened this issue May 17, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@mwotton
Copy link

mwotton commented May 17, 2023

Might it be possible to capture the state of the input to the test that failed? I know there's --falsify-replay for reproducibility, but ideally, I'd be able to capture the exact way that a test failed, generate the input off that state, and save it to a test database as something to try quickly, rather than have it spend ten minutes each time grinding through finding and shrinking a complex test case.

Obviously it's possible to just capture the actual input outside the library, but presumably there's some internal value that fully determines the smallest test case that falsify could find, and it could be fed back in as something to try? I'm willing to have a bit of a hack at implementation, but if it's all boiling down to the Word64 from prim, that would be far easier & more efficient to stash. (Obviously it would probably not be preserved as semantically interesting across versions of falsify)

https://hypothesis.readthedocs.io/en/latest/database.html

@mwotton
Copy link
Author

mwotton commented May 18, 2023

(had time to think about it as my current test has been running for 80 minutes)

so one option would be to just write an alternative tasty test provider that uses falsify and caches a map of types to serialised values from generators on disk. This would solve my immediate use case, but I don't think it's the right answer in some ways - if we change the definition of the underlying generator, it's possible that it could never actually generate that value, but we'd still be providing it, and it also requires some kind of serialisation scheme.

Does falsify have that same isomorphism as Hypothesis, where there's some mapping of random bits to every generated value, even the shrunken ones? If that exists, we're basically done, can just cache it as an input to feed back into the generator and use as a first test.

@edsko
Copy link
Collaborator

edsko commented May 26, 2023

In principle yes, although that mapping is finite only for shrunken values; but that should be enough for your use-case right? So yes, in principle it should be possible to create a database with serialized finite SampleTrees for specific shrunken counter-examples.

@edsko edsko added the enhancement New feature or request label Jun 5, 2023
@mwotton
Copy link
Author

mwotton commented Jun 8, 2023

thanks - sorry for delay, that's absolutely enough for my use case. If I get some free time I'll have a hack.

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

No branches or pull requests

2 participants