awslabs / shuttle

Shuttle is a library for testing concurrent Rust code
Apache License 2.0
620 stars 30 forks source link

Use of Shuttle for Rust async and #[tokio::main] #134

Open cameronelliott opened 5 months ago

cameronelliott commented 5 months ago

Hi, I am very interested in what Shuttle brings to the table for testing. As far as I can tell it is mostly designed for Rust sync code without #[tokio::main] main setups.

But I am a bit confused by the presences of the shuttle::future module. I am guessing it's really for sync programs which are invoking a little bit of async code?

It seems like if Shuttle was intended for testing mostly async programs, there would be replacement implementations for stuff like tokio::sync::Mutex (An asynchronous Mutex-like type).

Anyway I'd like to get some feedback about the suitability of Shuttle for testing mostly async functions and code.

Thank you. And thank you for creating Shuttle.

jorajeev commented 5 months ago

Shuttle does support checking async code; for instance you can find examples of checking code with mpsc channels from the futures crate in our tests.

To support code using libraries like tokio, there are two options: (1) recompile tokio code using Shuttle primitives (which, as you can imagine, is a lot of work and hard to maintain long-term), or (2) write your own replacements for tokio primitives in Shuttle (similar to how we've written replacements for std::sync primitives in the shuttle::sync module). We've done some early work on (2), but don't have anything ready to publish at the moment.