Skip to content

Commit

Permalink
test: reproduce transitive bindep dependency bug
Browse files Browse the repository at this point in the history
This is a unit test reproducing the bindep transitive dependency bug based upon example from rust-lang#11463

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed Dec 13, 2022
1 parent 7779606 commit 440517b
Showing 1 changed file with 130 additions and 0 deletions.
130 changes: 130 additions & 0 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2342,3 +2342,133 @@ fn calc_bin_artifact_fingerprint() {
)
.run();
}

#[cargo_test]
fn same_target_transitive_dependency_deduplication() {
// See:
// - https://github.com/rust-lang/cargo/issues/10837
// - https://github.com/rust-lang/cargo/issues/11463
let target = rustc_host();
let p = project()
.file(
"Cargo.toml",
&format!(
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
[dependencies]
a = {{ workspace = true }}
bar = {{ path = "bar", artifact = "bin", target = "{target}" }}
[workspace.dependencies]
a = {{ path = "a" }}
b = {{ path = "b" }}
c = {{ path = "c" }}
"#
),
)
.file(
"src/main.rs",
r#"
fn main() {}
"#,
)
.file(
"bar/Cargo.toml",
r#"
[package]
name = "bar"
version = "0.1.0"
[dependencies]
a = { workspace = true, features = ["feature"] }
"#,
)
.file(
"bar/src/main.rs",
r#"
fn main() {}
"#,
)
.file(
"a/Cargo.toml",
r#"
[package]
name = "a"
version = "0.1.0"
edition = "2021"
[dependencies]
b = { workspace = true }
c = { workspace = true }
[features]
feature = ["c/feature"]
"#,
)
.file(
"a/src/lib.rs",
r#"
use b::Trait as _;
pub fn use_b_trait(x: &impl c::Trait) {
x.b();
}
"#,
)
.file(
"b/Cargo.toml",
r#"
[package]
name = "b"
version = "0.1.0"
[dependencies]
c = { workspace = true }
"#,
)
.file(
"b/src/lib.rs",
r#"
pub trait Trait {
fn b(&self) {}
}
impl<T: c::Trait> Trait for T {}
"#,
)
.file(
"c/Cargo.toml",
r#"
[package]
name = "c"
version = "0.1.0"
[features]
feature = []
"#,
)
.file(
"c/src/lib.rs",
r#"
pub trait Trait {}
"#,
)
.build();
p.cargo("build -Z bindeps")
.masquerade_as_nightly_cargo(&["bindeps"])
.with_stderr(
"\
[COMPILING] c v0.1.0 ([CWD]/c)
[COMPILING] b v0.1.0 ([CWD]/b)
[COMPILING] a v0.1.0 ([CWD]/a)
[COMPILING] bar v0.1.0 ([CWD]/bar)
[COMPILING] foo v0.1.0 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
)
.run();
}

0 comments on commit 440517b

Please sign in to comment.