diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index adf144ac2ed4..b6df6979fb71 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -104,6 +104,10 @@ pub fn run( process.display_env_vars(); } + if let Some(client) = config.jobserver_from_env() { + process.inherit_jobserver(client); + } + config.shell().status("Running", process.to_string())?; process.exec_replace() diff --git a/tests/testsuite/jobserver.rs b/tests/testsuite/jobserver.rs index 39c8e5ede166..56d8e7c7582a 100644 --- a/tests/testsuite/jobserver.rs +++ b/tests/testsuite/jobserver.rs @@ -134,11 +134,10 @@ all: ) .build(); - p.process(make).env("CARGO", cargo_exe()).arg("-j2") - .with_status(2) - .with_stderr_contains("[..]no jobserver from env[..]") - .run(); + // jobserver can be inherited from env + p.process(make).env("CARGO", cargo_exe()).arg("-j2").run(); + // but not from `-j` flag p.cargo("run -j2") .with_status(101) .with_stderr_contains("[..]no jobserver from env[..]")