Checks for calls to non-thread-safe functions in code attributed with
#[test]. For this lint to be effective, --tests must be passed to cargo check.
“When you run multiple tests, by default they run in parallel using threads” (reference). Calling a non-thread-safe function in one test could affect the outcome of another.
std::process::Command::new("cargo").arg("run"), but does not track
values. So false negatives will result if the Command::new("cargo") is not
Command::arg("run")’s receiver.#[test]
fn set_var() {
std::env::set_var("KEY", "SOME_VALUE");
std::process::Command::new("env").status().unwrap();
}
Use instead:
#[test]
fn set_var() {
std::process::Command::new("env")
.env("KEY", "SOME_VALUE")
.status()
.unwrap();
}