From 2d23b94a7f5f86bdf74fd5da2617e82ffad1f222 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 13 Dec 2024 11:00:04 -0600 Subject: [PATCH] test(base): Verify bases in patches in virtual manifests --- tests/testsuite/patch.rs | 69 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/tests/testsuite/patch.rs b/tests/testsuite/patch.rs index e3e14b90587..eb5efd4c33b 100644 --- a/tests/testsuite/patch.rs +++ b/tests/testsuite/patch.rs @@ -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")) @@ -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 = ["wycats@example.com"] + 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(); +}