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

feat: add run interface #261

Merged
merged 1 commit into from
Nov 26, 2024
Merged

feat: add run interface #261

merged 1 commit into from
Nov 26, 2024

Conversation

camshaft
Copy link
Owner

@camshaft camshaft commented Nov 26, 2024

This change adds the ability to use generator functions inside of harnesses without having to specify the inputs up front.

use bolero::*;

check!().run(|| {
    let _ = any::<u64>();
    let _ = (0..4).any();
    let _ = [1, 2, 3].pick();
    let _ = gen::<Vec<u8>>().with().len(2..4).any();
});

Note that there are a couple of caveats to this interface:

  • This uses thread-local variables for each call to any, which can have a bit of overhead, so it's generally preferred to use the .with_type and .with_generator if possible
  • The harness does not currently track inputs for displaying when things fail so it may be a bit more difficult to debug. This may change in the future.
  • Shrinking is currently not implemented but will be at a later time.

@camshaft camshaft force-pushed the engine-any branch 2 times, most recently from 4a20774 to 4998629 Compare November 26, 2024 23:25
@camshaft camshaft changed the title feat: add support for calling generators from anywhere feat: add run interface Nov 26, 2024
@camshaft camshaft marked this pull request as ready for review November 26, 2024 23:54
@camshaft camshaft merged commit 9e0c56e into master Nov 26, 2024
9 checks passed
@camshaft camshaft deleted the engine-any branch November 26, 2024 23:54
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.

1 participant