Skip to content

Commit

Permalink
test(bindeps): assumed host target and optional = true coexist
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Dec 4, 2022
1 parent 437bed0 commit 7dcb6da
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2394,3 +2394,47 @@ fn with_target_and_optional() {
.with_status(101)
.run();
}

#[cargo_test]
fn with_assumed_host_target_and_optional_build_dep() {
// This exercises an incorrect behaviour got to be fixed by the following commit.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
edition = "2021"
[build-dependencies]
d1 = { path = "d1", artifact = "bin", optional = true, target = "target" }
"#,
)
.file("src/main.rs", "fn main() {}")
.file(
"build.rs",
r#"
fn main() {
std::env::var("CARGO_BIN_FILE_D1").unwrap();
}
"#,
)
.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_status(101)
.with_stderr_contains("[ERROR] failed to run custom build command for `foo v0.0.1 ([..])`")
.with_stderr_contains("[..]thread '[..]' panicked at 'called `Result::unwrap()`[..]")
.run();
}

0 comments on commit 7dcb6da

Please sign in to comment.