Skip to content

Commit

Permalink
test(base): Verify bases in patches in virtual manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Dec 13, 2024
1 parent e83dc04 commit 2d23b94
Showing 1 changed file with 68 additions and 1 deletion.
69 changes: 68 additions & 1 deletion tests/testsuite/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3038,7 +3038,7 @@ foo v0.0.0 ([ROOT]/foo)
}

#[cargo_test]
fn patch_with_base() {
fn patch_in_real_with_base() {
let bar = project()
.at("bar")
.file("Cargo.toml", &basic_manifest("bar", "0.5.0"))
Expand Down Expand Up @@ -3087,3 +3087,70 @@ foo v0.5.0 ([ROOT]/foo)
"#]])
.run();
}

#[cargo_test]
fn patch_in_virtual_with_base() {
let bar = project()
.at("bar")
.file("Cargo.toml", &basic_manifest("bar", "0.5.0"))
.file("src/lib.rs", "pub fn hello() {}")
.build();
Package::new("bar", "0.5.0").publish();

let p = project()
.file(
".cargo/config.toml",
&format!(
r#"
[path-bases]
test = '{}'
"#,
bar.root().parent().unwrap().display()
),
)
.file(
"Cargo.toml",
r#"
cargo-features = ["path-bases"]
[workspace]
members = ["foo"]
[patch.crates-io]
bar = { base = 'test', path = 'bar' }
"#,
)
.file(
"foo/Cargo.toml",
r#"
[package]
name = "foo"
version = "0.5.0"
authors = ["[email protected]"]
edition = "2018"
[dependencies]
bar = "0.5.0"
"#,
)
.file("foo/src/lib.rs", "use bar::hello as _;")
.build();

p.cargo("tree")
.masquerade_as_nightly_cargo(&["path-bases"])
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] failed to load source for dependency `bar`
Caused by:
Unable to update [ROOT]/foo/bar
Caused by:
failed to read `[ROOT]/foo/bar/Cargo.toml`
Caused by:
[NOT_FOUND]
"#]])
.run();
}

0 comments on commit 2d23b94

Please sign in to comment.