Attribute Macro serial_test::file_serial

source ·
#[file_serial]
Available on crate feature file_locks only.
Expand description

Allows for the creation of file-serialised Rust tests

#[test]
#[file_serial]
fn test_serial_one() {
  // Do things
}

#[test]
#[file_serial]
fn test_serial_another() {
  // Do things
}

Multiple tests with the file_serial attribute are guaranteed to run in serial, as per the serial attribute. Note that there are no guarantees about one test with serial and another with file_serial as they lock using different methods, and file_serial does not support nested serialised tests, but otherwise acts like serial. If you have other tests that can be run in parallel, but would clash if run at the same time as the file_serial tests, you can use the file_parallel attribute.

It also supports an optional path arg as well as key(s) as per serial.

#[test]
#[file_serial(key)]
fn test_serial_one() {
  // Do things
}

#[test]
#[file_serial(key, path => "/tmp/foo")]
fn test_serial_another() {
  // Do things
}

The path defaults to a reasonable temp directory for the OS if not specified. If the path is specified, you can only use one key.