test-with-tokio

This crate provides a single attribute macro #[test_with(GUARDEXPRESSION)] which allows you to provide a guard expression, and is otherwise like #[tokio::test] with fewer bells and whistles (apart from the guard). It enables you to run most of your tests in parallel, but to have a few that cannot be run concurrently. ```

[test]

fn thistestcanrunwith_anything() { ... }

static DIRECTORY_LOCK: std::sync::RwLock<()> = std::sync::RwLock::new(());

/// This test cannot be run alongside any tests that use the directory.

[testwith(DIRECTORYLOCK.write().unwrap())]

fn evil_test() { ... }

/// This test can be run with other tests using the directory, but not with the evil test.

[testwith({ DIRECTORYLOCK.read().unwrap()})]

fn nicer_test() { ... } `` You might wonder, why not take the lock within a function marked with #[tokio::test]? The answer lies in the lack of anasyncDrop`. This means that the evil test isn't fully cleaned up until after the tokio wrapper exits, which is after the body of your test function has exited and released the lock.