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

Support for tokio single-threaded runtime #11

Open
xfbs opened this issue Feb 17, 2024 · 1 comment
Open

Support for tokio single-threaded runtime #11

xfbs opened this issue Feb 17, 2024 · 1 comment

Comments

@xfbs
Copy link

xfbs commented Feb 17, 2024

Hey! Love this crate. Was wondering if you think it made sense for me to add support for a tokio single-threaded runtime. I think that might be advantageous.

@frozenlib
Copy link
Owner

I have added support for specifying functions to execute asynchronous blocks in #[proptes(async = ...)]. (351a36f)

Using this feature, you can write a test using tokio's single-threaded runtime as follows

use std::future::Future;

use proptest::{prop_assert, test_runner::TestCaseError};
use test_strategy::proptest;

fn tokio_ct(future: impl Future<Output = Result<(), TestCaseError>>) -> Result<(), TestCaseError> {
    tokio::runtime::Builder::new_current_thread().build().unwrap().block_on(future)
}

#[proptest(async = tokio_ct)]
async fn async_expr() {
    prop_assert!(true);
    tokio::task::yield_now().await;
}

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

No branches or pull requests

2 participants