nonparallel
:warning: Note: This crate is deprecated and unmaintained. You should use
serial_test
instead, which is more powerful thannonparallel
.
A procedural macro for Rust that allows you to ensure that functions are not running at the same time. This is especially useful for integration tests, where tests that are writing to the same database table should not run in parallel.
The goal of mutual exclusion is achieved by acquiring a mutex at the beginning
of the annotated function. So in essence this macro is syntactical sugar for
writing MUT.lock().unwrap()
at the beginning of every function.
Different functions can synchronize on different mutexes. That's why a
static mutex reference must be passed to the nonparallel
annotation.
Usage
use Mutex;
use lazy_static;
use nonparallel;
// Create two locks
lazy_static!
lazy_static!
// Mutually exclude parallel runs of functions using those two locks
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.