diff --git a/tests/testsuite/jobserver.rs b/tests/testsuite/jobserver.rs index ed5352c82be8..39c8e5ede166 100644 --- a/tests/testsuite/jobserver.rs +++ b/tests/testsuite/jobserver.rs @@ -12,7 +12,7 @@ const EXE_CONTENT: &str = r#" use std::env; fn main() { - let var = env::var("CARGO_MAKEFLAGS").unwrap(); + let var = env::var("CARGO_MAKEFLAGS").expect("no jobserver from env"); let arg = var.split(' ') .find(|p| p.starts_with("--jobserver")) .unwrap(); @@ -105,6 +105,46 @@ all: p.process(make).env("CARGO", cargo_exe()).arg("-j2").run(); } +#[cargo_test] +fn cargo_run_inherits_jobserver() { + let make = make_exe(); + if Command::new(make).arg("--version").output().is_err() { + return; + } + + let name = "cargo-jobserver-check"; + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [package] + name = "{name}" + version = "0.0.1" + "# + ), + ) + .file("src/main.rs", EXE_CONTENT) + .file( + "Makefile", + "\ +all: +\t+$(CARGO) run +", + ) + .build(); + + p.process(make).env("CARGO", cargo_exe()).arg("-j2") + .with_status(2) + .with_stderr_contains("[..]no jobserver from env[..]") + .run(); + + p.cargo("run -j2") + .with_status(101) + .with_stderr_contains("[..]no jobserver from env[..]") + .run(); +} + #[cargo_test] fn makes_jobserver_used() { let make = make_exe();