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

[replays-dont-count-cases] #295

Merged
merged 1 commit into from
Feb 5, 2023
Merged

[replays-dont-count-cases] #295

merged 1 commit into from
Feb 5, 2023

Conversation

rex-remind101
Copy link
Collaborator

@rex-remind101 rex-remind101 commented Jan 25, 2023

replays/persisted failures are not counted against successful cases.

this way when PROPTEST_CASES <= number of persisted cases we will not end up never creating new cases to test against. rather, all persisted cases will be tested and then a new number of cases will run equal to the number of PROPTEST_CASES.

addresses #290

Comment on lines 45 to 51
pub(crate) enum TestCaseOk {
NewCaseSuccess,
ReplaySuccess,
CacheHitSuccess,
Reject,
}
Copy link
Member

Choose a reason for hiding this comment

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

Not expecting any changes inline to this PR as these thoughts aren't fully baked but wanted to run some stuff by you and see how you're thinking of these things. Also since this is a crate-private type, we can evolve this independently of crate version so that gives us some flexibility for the future.

I've been thinking of how to add some new functionality to support #284 (providing manual, explicit cases) and was thinking of introducing a new wrapper type for cases that carry context on their source so we can have something like:

enum Case<T: fmt::Debug, S: Strategy<Value=T>> {
    UserProvided(T),    
    Generated(S),
    Persisted(S, Seed),
    Replay(S, TestCaseResult),
}

or something along these lines and then the test-runner code can branch on these accordingly to affect seed, success counts, whether we actually run the test or just emulate it based on replay value, etc.

We could be left with a result type of:

enum TestCaseOk {
    Success,
    CacheHit,
    Reject,
}

Not entirely sure all this would end up working out with the current code structure as I haven't actually started implementing it.

Copy link
Member

Choose a reason for hiding this comment

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

And more direct comment on this code after reading some more below, I think we'd want a PersistedCaseSuccess variant. Right now it seems ReplaySuccess is being overloaded for both persisted tests as well as forked tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that seems like a good approach to me 👍

result
result.map(|_| {
if is_from_persisted_seed {
TestCaseOk::ReplaySuccess
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the right return value. we're actually running the test for this result so its not really a "replay" in the context of what "replay" means for forked tests. I commented on the enum def as well but to be explicit, what do you think about a PersistedCaseSuccess variant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good call out, will make that change 👍

Comment on lines 565 to 568
// Since all of our test runs happened in forks already, we need to
// force the runner to count successful replays against our total
// success count.
true,
Copy link
Member

Choose a reason for hiding this comment

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

not a huge fan of having boolean flags flip behavior like this. having explicit variants for PersistedCaseSuccess and ReplaySuccess would remove the need for this right? I think we always want replays to count against the success count and we never want persisted cases to count against success count.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

@rex-remind101 rex-remind101 force-pushed the replays-dont-count-cases branch 2 times, most recently from 35ad221 to 5ec56a6 Compare January 31, 2023 04:37
… successful cases.

this way when `PROPTEST_CASES` <= `number of persisted cases` we
will not end up never creating new cases to test against. rather,
all persisted cases will be tested _and then_ a new number of cases
will run equal to the number of `PROPTEST_CASES`.
Copy link
Member

@cameron1024 cameron1024 left a comment

Choose a reason for hiding this comment

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

Apologies for taking so long looking into this 😅

Code looks good, one minor thought I have is that it may be surprising to users if you have PROPTEST_CASES=1 and it still runs multiple tests. This is something I do fairly frequently - I have some tests that take a fairly long time to run, so want to only run it once for a shorter local dev cycle.

At the very least, we should document this (though IIRC the new behaviour is what the documentation said, if so, then that's probably fine).

Perhaps it's worth adding something like PROPTEST_TOTAL_CASES or something, to set an absolute limit on the number of tests run, even if that means skipping known regressions. Though that's for sure out of scope for this PR. I'm just not sure about whether it's something we should block 1.1 on

@cameron1024 cameron1024 merged commit a7c75a1 into master Feb 5, 2023
@cameron1024 cameron1024 deleted the replays-dont-count-cases branch February 5, 2023 18:36
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.

None yet

3 participants