mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
test(bindeps): target field specified and optional = true
coexist
This commit is contained in:
parent
7bdb96929d
commit
437bed069a
@ -2342,3 +2342,55 @@ fn calc_bin_artifact_fingerprint() {
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn with_target_and_optional() {
|
||||
// This is a incorrect behaviour got to be fixed.
|
||||
// See rust-lang/cargo#10526
|
||||
if cross_compile::disabled() {
|
||||
return;
|
||||
}
|
||||
let target = cross_compile::alternate();
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
&r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
[dependencies]
|
||||
d1 = { path = "d1", artifact = "bin", optional = true, target = "$TARGET" }
|
||||
"#
|
||||
.replace("$TARGET", target),
|
||||
)
|
||||
.file(
|
||||
"src/main.rs",
|
||||
r#"
|
||||
fn main() {
|
||||
let _b = include_bytes!(env!("CARGO_BIN_FILE_D1"));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"d1/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "d1"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
"#,
|
||||
)
|
||||
.file("d1/src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("check -Z bindeps -F d1 -v")
|
||||
.masquerade_as_nightly_cargo(&["bindeps"])
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[ERROR] environment variable `CARGO_BIN_FILE_D1` not defined
|
||||
",
|
||||
)
|
||||
.with_status(101)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user