From 5fa43ee1c5d282224f1b98c288b924a9389094ba Mon Sep 17 00:00:00 2001 From: Guillaume Dallenne Date: Wed, 11 Sep 2024 11:24:06 +0200 Subject: [PATCH] test(vendor): add test case updating git dependency without version change --- tests/testsuite/vendor.rs | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/testsuite/vendor.rs b/tests/testsuite/vendor.rs index 7f7ef2b24a6..2d3ffe0bace 100644 --- a/tests/testsuite/vendor.rs +++ b/tests/testsuite/vendor.rs @@ -1568,6 +1568,67 @@ path = [..] ); } +#[cargo_test] +fn git_update_rev() { + let (git_project, git_repo) = git::new_repo("git", |p| { + p.file("Cargo.toml", &basic_manifest("a", "0.1.0")) + .file("src/lib.rs", "") + }); + let url = git_project.url(); + let ref_1 = "initial"; + let ref_2 = "update"; + + git::tag(&git_repo, ref_1); + + git_project.change_file("src/lib.rs", "pub fn f() {}"); + git::add(&git_repo); + git::commit(&git_repo); + git::tag(&git_repo, ref_2); + + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + a = {{ git = '{url}', rev = '{ref_1}' }} + "# + ), + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("vendor --respect-source-config --versioned-dirs") + .run(); + + let lib = p.read_file("vendor/a-0.1.0/src/lib.rs"); + assert_e2e().eq(lib, ""); + + p.change_file( + "Cargo.toml", + &format!( + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + a = {{ git = '{url}', rev = '{ref_2}' }} + "# + ), + ); + + p.cargo("vendor --respect-source-config --versioned-dirs") + .run(); + + let lib = p.read_file("vendor/a-0.1.0/src/lib.rs"); + assert_e2e().eq(lib, ""); +} + #[cargo_test] fn depend_on_vendor_dir_not_deleted() { let p = project()