Skip to content

Commit

Permalink
test(bindeps): target field specified and optional = true coexist
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Nov 28, 2022
1 parent 1382b44 commit 0668547
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2342,3 +2342,55 @@ fn calc_bin_artifact_fingerprint() {
)
.run();
}

#[cargo_test]
fn build_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("build -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();
}

0 comments on commit 0668547

Please sign in to comment.