Skip to content

Commit

Permalink
test: verify cargo-run doesn't inherit jobserver
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Oct 6, 2023
1 parent cd5d793 commit 8d8243d
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion tests/testsuite/jobserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 8d8243d

Please sign in to comment.