mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
test(cargo-rustc): show the current precedence
This commit is contained in:
parent
cf781daeb7
commit
7ded268948
@ -795,3 +795,67 @@ windows
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn precedence() {
|
||||
// Ensure that the precedence of cargo-rustc is only lower than RUSTFLAGS,
|
||||
// but higher than most flags set by cargo.
|
||||
//
|
||||
// See rust-lang/cargo#14346
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
edition = "2021"
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = "allow"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("rustc --release -v -- --cfg cargo_rustc -C strip=symbols")
|
||||
.env("RUSTFLAGS", "--cfg from_rustflags")
|
||||
.with_stderr_data(
|
||||
str![[r#"
|
||||
[COMPILING] foo v0.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]--cfg cargo_rustc -C strip=symbols [..]-C strip=debuginfo [..]--cfg from_rustflags`
|
||||
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
|
||||
|
||||
"#]]
|
||||
)
|
||||
.run();
|
||||
|
||||
// Ensure the short-live env var to work
|
||||
p.cargo("clean").run();
|
||||
p.cargo("rustc --release -v -- --cfg cargo_rustc -C strip=symbols")
|
||||
.env("RUSTFLAGS", "--cfg from_rustflags")
|
||||
.env("__CARGO_RUSTC_ORIG_ARGS_PRIO", "1")
|
||||
.masquerade_as_nightly_cargo(&["cargo-rustc-precedence"])
|
||||
.with_stderr_data(
|
||||
str![[r#"
|
||||
[COMPILING] foo v0.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]--cfg cargo_rustc -C strip=symbols [..]-C strip=debuginfo [..]--cfg from_rustflags`
|
||||
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
|
||||
|
||||
"#]]
|
||||
)
|
||||
.run();
|
||||
|
||||
// Ensure non-nightly to work as before
|
||||
p.cargo("clean").run();
|
||||
p.cargo("rustc --release -v -- --cfg cargo_rustc -C strip=symbols")
|
||||
.env("RUSTFLAGS", "--cfg from_rustflags")
|
||||
.with_stderr_data(
|
||||
str![[r#"
|
||||
[COMPILING] foo v0.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]--cfg cargo_rustc -C strip=symbols [..]-C strip=debuginfo [..]--cfg from_rustflags`
|
||||
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
|
||||
|
||||
"#]]
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user