Skip to content

Commit

Permalink
test: show runtime-dep and build-dep collides
Browse files Browse the repository at this point in the history
See #14253
  • Loading branch information
weihanglo committed Aug 20, 2024
1 parent 3ef3f61 commit 960adae
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/testsuite/rustflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1642,3 +1642,62 @@ fn target_applies_to_host_rustdocflags_works() {
)
.run();
}

#[cargo_test]
fn host_config_shared_build_dep() {
// rust-lang/cargo#14253
Package::new("cc", "1.0.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "bootstrap"
edition = "2021"
[dependencies]
cc = "1.0.0"
[build-dependencies]
cc = "1.0.0"
[profile.dev]
debug = 0
"#,
)
.file("src/lib.rs", "")
.file("build.rs", "fn main() {}")
.build();

p.cargo("build")
.masquerade_as_nightly_cargo(&["target-applies-to-host"])
.arg("-Ztarget-applies-to-host")
.arg("--config=target-applies-to-host=false")
.env("RUSTFLAGS", "--cfg foo")
.with_status(101)
// Sometimes it compiles. Not deterministic...
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[LOCKING] 2 packages to latest compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] cc v1.0.0 (registry `dummy-registry`)
[WARNING] output filename collision.
The lib target `cc` in package `cc v1.0.0` has the same output filename as the lib target `cc` in package `cc v1.0.0`.
Colliding filename is: [ROOT]/foo/target/debug/deps/libcc-[HASH].rlib
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
[WARNING] output filename collision.
The lib target `cc` in package `cc v1.0.0` has the same output filename as the lib target `cc` in package `cc v1.0.0`.
Colliding filename is: [ROOT]/foo/target/debug/deps/libcc-[HASH].rmeta
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
[COMPILING] cc v1.0.0
[ERROR] failed to build archive: No such file or directory
[ERROR] could not compile `cc` (lib) due to 1 previous error
"#]])
.run();
}

0 comments on commit 960adae

Please sign in to comment.