Skip to content

Commit c607b5f

Browse files
committed
Add test: patch with different ver on same pkg
1 parent 9b4a501 commit c607b5f

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

tests/testsuite/patch.rs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,3 +2914,123 @@ Caused by:
29142914
)
29152915
.run();
29162916
}
2917+
2918+
#[cargo_test]
2919+
fn patch_on_same_package_with_different_version() {
2920+
let p = project()
2921+
.file(
2922+
"Cargo.toml",
2923+
r#"
2924+
[package]
2925+
name = "cargo-bug-repo"
2926+
version = "0.1.0"
2927+
edition = "2015"
2928+
2929+
[dependencies]
2930+
foo = { path = "vendor/foo" }
2931+
bar = { path = "vendor/bar" }
2932+
2933+
[patch.crates-io]
2934+
once_cell_0_1 = { package = "once_cell", path = "vendor/once_cell_0_1" }
2935+
once_cell_1_19 = { package = "once_cell", path = "vendor/once_cell_1_19" }
2936+
"#,
2937+
)
2938+
.file(
2939+
"src/main.rs",
2940+
r#"
2941+
extern crate foo;
2942+
extern crate bar;
2943+
fn main() {
2944+
foo::print_version();
2945+
bar::print_version();
2946+
}
2947+
"#,
2948+
)
2949+
.file(
2950+
"vendor/bar/src/lib.rs",
2951+
r#"
2952+
extern crate once_cell;
2953+
pub fn print_version() {
2954+
dbg!(once_cell::version());
2955+
}
2956+
"#,
2957+
)
2958+
.file(
2959+
"vendor/bar/Cargo.toml",
2960+
r#"
2961+
[package]
2962+
name = "bar"
2963+
version = "0.1.0"
2964+
edition = "2015"
2965+
2966+
[dependencies]
2967+
once_cell = "1.19"
2968+
"#,
2969+
)
2970+
.file(
2971+
"vendor/foo/src/lib.rs",
2972+
r#"
2973+
extern crate once_cell;
2974+
pub fn print_version() {
2975+
dbg!(once_cell::version());
2976+
}
2977+
"#,
2978+
)
2979+
.file(
2980+
"vendor/foo/Cargo.toml",
2981+
r#"
2982+
[package]
2983+
name = "foo"
2984+
version = "0.1.0"
2985+
edition = "2015"
2986+
2987+
[dependencies]
2988+
once_cell = "0.1"
2989+
"#,
2990+
)
2991+
.file(
2992+
"vendor/once_cell_0_1/src/lib.rs",
2993+
r#"
2994+
pub fn version() -> &'static str {
2995+
"0.1.0"
2996+
}
2997+
"#,
2998+
)
2999+
.file(
3000+
"vendor/once_cell_0_1/Cargo.toml",
3001+
&basic_manifest("once_cell", "0.1.0"),
3002+
)
3003+
.file(
3004+
"vendor/once_cell_1_19/src/lib.rs",
3005+
r#"
3006+
pub fn version() -> &'static str {
3007+
"1.19.0"
3008+
}
3009+
"#,
3010+
)
3011+
.file(
3012+
"vendor/once_cell_1_19/Cargo.toml",
3013+
&basic_manifest("once_cell", "1.19.0"),
3014+
)
3015+
.build();
3016+
3017+
p.cargo("check")
3018+
.with_stderr(
3019+
"\
3020+
[UPDATING] crates.io index
3021+
[LOCKING] 5 packages to latest compatible versions
3022+
[CHECKING] once_cell [..] ([CWD]/vendor/once_cell_[..])
3023+
[CHECKING] once_cell [..] ([CWD]/vendor/once_cell_[..])
3024+
[CHECKING] [..] v0.1.0 ([CWD]/vendor/[..])
3025+
[CHECKING] [..] v0.1.0 ([CWD]/vendor/[..])
3026+
[CHECKING] cargo-bug-repo v0.1.0 ([CWD])
3027+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
3028+
",
3029+
)
3030+
.run();
3031+
3032+
p.cargo("check").with_stderr("\
3033+
[UPDATING] crates.io index
3034+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
3035+
").run();
3036+
}

0 commit comments

Comments
 (0)