test: external subcommand inherits jobserver

This commit is contained in:
Weihang Lo 2022-03-26 18:08:11 +08:00
parent b1636fc1e0
commit b099d39112
No known key found for this signature in database
GPG key ID: D7DBF189825E82E7

View file

@ -4,14 +4,10 @@ use std::net::TcpListener;
use std::process::Command;
use std::thread;
use cargo_test_support::install::{assert_has_installed_exe, cargo_home};
use cargo_test_support::{cargo_exe, project};
#[cargo_test]
fn jobserver_exists() {
let p = project()
.file(
"build.rs",
r#"
const EXE_CONTENT: &str = r#"
use std::env;
fn main() {
@ -46,8 +42,12 @@ fn jobserver_exists() {
fn validate(_: &str) {
// a little too complicated for a test...
}
"#,
)
"#;
#[cargo_test]
fn jobserver_exists() {
let p = project()
.file("build.rs", EXE_CONTENT)
.file("src/lib.rs", "")
.build();
@ -57,6 +57,45 @@ fn jobserver_exists() {
p.cargo("build -j2").run();
}
#[cargo_test]
fn external_subcommand_inherits_jobserver() {
let make = if cfg!(windows) {
"mingw32-make"
} else {
"make"
};
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) jobserver-check
",
)
.build();
p.cargo("install --path .").run();
assert_has_installed_exe(cargo_home(), name);
p.process(make).env("CARGO", cargo_exe()).arg("-j2").run();
}
#[cargo_test]
fn makes_jobserver_used() {
let make = if cfg!(windows) {