-
Notifications
You must be signed in to change notification settings - Fork 131
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 proptest support #68
Conversation
Signed-off-by: Ana Hobden <operator@hoverbear.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would this look like using proptest without proptest-derive? Could we separate the proptest stuff from the rest of kv.rs? I'm a bit worried about how noisy the proptest-derive attributes make that module, and if we're supporting more in the future it might make things quite hard to read.
tests/integration/raw.rs
Outdated
|
||
block_on( | ||
client.put(pair.key().clone(), pair.value().clone()) | ||
).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use await
rather than block_on
since the latter does not permit concurrency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would too!
But, the proptest
macro isn't compatible with async/await, I tried using a bare approach with async
test functions but since the TestRunner
operates in a closure (that doesn't return a result or an async) you can't use .await
or ?
anyways.
I'm considering trying to patch this upstream, but in the meantime, this seems easiest as it avoids a fair bit of testrunner/handling boilerplate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking you would just use another function and call that from the test function, but if you think that is not worth the boilerplate, then we can keep things like this
Signed-off-by: Ana Hobden <operator@hoverbear.org>
From #69, I'm now thinking whether we need the prop testing features at all - what is the advantage over just having them always on (if integration testing is on)? |
@nrc I can imagine a very valid future case where we will want property testing on for use in non-integration tests, and it is handy to support it for downstream users. |
Agree. I mean why not have it always on? |
@nrc Because some users won't want to build proptest during release etc. (Compile times, complexity). This lets users opt into the dependency. |
Can we make proptest a dev dependency for that reason? |
It is, but I think that it's possible users might want this, and that letting it be opt-in is not very complex. |
Hmm, I think it is worth stepping back a bit since I think we have different goals here :-) My mental model is that we have two audiences - those using the client as a dependency and those developing the client. The former don't want to run any tests and want compilation to be as fast as possible. They want features to opt-in to some functionality or to support platform-specific functionality, e.g., encryption or async/await support. Developers also want fast compilation, but want to run tests. IMO, the best developer experience is when So, in general, my motivation for wanting to avoid a feature here is that I want to avoid the complexity of having features (having to think about them when building/testing, working out how they interact with each other, ensuring the right defaults, etc) and I want local tests to be similar to CI tests. I'm trying to understand the motivation for including the feature - is it because the property tests take a long time? Or are not widely useful? Or that the dependencies take a long time to build? IOW, what is the benefit to the developer that outweighs the costs of added complexity and not running tests? |
@nrc Consider three use cases:
As you can see, we're enabling proptest always on dev builds, but only on opt-in for folks depending on us. (at least as far as I'm able to tell from looking at the dependencies) Is my understanding of how features and dev/normal dependencies incorrect? |
Signed-off-by: Ana Hobden <operator@hoverbear.org>
@nrc The merge above is non-trivial, but there were conflicts with master and reorganizing in the merge ended up cleaner. The merge moved all the proptests into Note we have to have things inside Overall I think this solution is much cleaner and simpler. Thanks for your feedback :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Ana Hobden <operator@hoverbear.org>
Adds
proptest
support (feature gated behindproperty-testing
) for integration tests or user use.I made this a feature so that any users using proptest could easily call
any::<Key>
for example.I'll be amending #66 to base off this PR since it's a much nicer way.