Skip to content

Commit 4d094c0

Browse files
committed
Add a test to model the bug found in #7346
1 parent bcb89d1 commit 4d094c0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tests/testsuite/patch.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,63 @@ fn transitive_new_major() {
735735
.run();
736736
}
737737

738+
#[cargo_test]
739+
fn shared_by_transitive() {
740+
Package::new("baz", "0.1.1").publish();
741+
742+
let baz = git::repo(&paths::root().join("override"))
743+
.file("Cargo.toml", &basic_manifest("baz", "0.1.2"))
744+
.file("src/lib.rs", "")
745+
.build();
746+
747+
let p = project()
748+
.file(
749+
"Cargo.toml",
750+
&format!(
751+
r#"
752+
[package]
753+
name = "foo"
754+
version = " 0.1.0"
755+
756+
[dependencies]
757+
bar = {{ path = "bar" }}
758+
baz = "0.1"
759+
760+
[patch.crates-io]
761+
baz = {{ git = "{}", version = "0.1" }}
762+
"#,
763+
baz.url(),
764+
),
765+
)
766+
.file("src/lib.rs", "")
767+
.file(
768+
"bar/Cargo.toml",
769+
r#"
770+
[package]
771+
name = "bar"
772+
version = "0.1.0"
773+
774+
[dependencies]
775+
baz = "0.1.1"
776+
"#,
777+
)
778+
.file("bar/src/lib.rs", "")
779+
.build();
780+
781+
p.cargo("build")
782+
.with_stderr(
783+
"\
784+
[UPDATING] git repository `file://[..]`
785+
[UPDATING] `[ROOT][..]` index
786+
[COMPILING] baz v0.1.2 [..]
787+
[COMPILING] bar v0.1.0 [..]
788+
[COMPILING] foo v0.1.0 ([CWD])
789+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
790+
",
791+
)
792+
.run();
793+
}
794+
738795
#[cargo_test]
739796
fn remove_patch() {
740797
Package::new("foo", "0.1.0").publish();

0 commit comments

Comments
 (0)