Skip to content

Commit

Permalink
Add test for vendor with different revs from same git repo
Browse files Browse the repository at this point in the history
Signed-off-by: Atkins Chang <[email protected]>
  • Loading branch information
AtkinsChang committed May 13, 2022
1 parent 6d6dd9d commit 2a3dcc5
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion tests/testsuite/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::fs;

use cargo_test_support::git;
use cargo_test_support::registry::{self, Package};
use cargo_test_support::{basic_lib_manifest, paths, project, Project};
use cargo_test_support::{basic_lib_manifest, basic_manifest, paths, project, Project};

#[cargo_test]
fn vendor_simple() {
Expand Down Expand Up @@ -596,6 +596,62 @@ fn git_simple() {
assert!(csum.contains("\"package\":null"));
}

#[cargo_test]
fn git_diff_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 = "v0.1.0";
let ref_2 = "v0.2.0";

git::tag(&git_repo, ref_1);

git_project.change_file("Cargo.toml", &basic_manifest("a", "0.2.0"));
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_1 = {{ package = "a", git = '{url}', rev = '{ref_1}' }}
a_2 = {{ package = "a", git = '{url}', rev = '{ref_2}' }}
"#
),
)
.file("src/lib.rs", "")
.build();

p.cargo("vendor --respect-source-config")
.stream()
.with_stdout(
r#"
[source.[..]]
git = [..]
rev = "v0.1.0"
replace-with = "vendored-sources"
[source.[..]]
git = [..]
rev = "v0.2.0"
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
"#,
)
.run();
}

#[cargo_test]
fn git_duplicate() {
let git = git::new("a", |p| {
Expand Down

0 comments on commit 2a3dcc5

Please sign in to comment.