mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 19:22:33 +00:00
test: external subcommand inherits jobserver
This commit is contained in:
parent
b1636fc1e0
commit
b099d39112
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue