sequential

Function sequential 

Source
pub fn sequential<'a>() -> MutexGuard<'a, ()>
Expand description

Allow tests with side-effects to run without interfering with each other. The lock is released when the MutexGuard variable goes out of scope. Will ignore poison errors from other tests so that our test can continue even if theirs fails.

Use this when working with global variables, OS calls, the file system, or other shared resources.

§Example

use common_testing::setup;

#[test]
fn test_1() {
  let _lock = setup::sequential();
  // test code
}

#[test]
fn test_2() {
  let _lock = setup::sequential();
  // test code
}

§See Also

std::sync::Mutex::lock

std::sync::PoisonError