Skip to content

Commit 0200d3b

Browse files
committed
Add test for vendor with different revs from same git repo
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
1 parent 74c7aab commit 0200d3b

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

tests/testsuite/vendor.rs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::fs;
88

99
use cargo_test_support::git;
1010
use cargo_test_support::registry::{self, Package, RegistryBuilder};
11-
use cargo_test_support::{basic_lib_manifest, paths, project, Project};
11+
use cargo_test_support::{basic_lib_manifest, basic_manifest, paths, project, Project};
1212

1313
#[cargo_test]
1414
fn vendor_simple() {
@@ -675,6 +675,60 @@ fn git_simple() {
675675
assert!(csum.contains("\"package\":null"));
676676
}
677677

678+
#[cargo_test]
679+
fn git_diff_rev() {
680+
let (git_project, git_repo) = git::new_repo("git", |p| {
681+
p.file("Cargo.toml", &basic_manifest("a", "0.1.0"))
682+
.file("src/lib.rs", "")
683+
});
684+
let url = git_project.url();
685+
let ref_1 = "v0.1.0";
686+
let ref_2 = "v0.2.0";
687+
688+
git::tag(&git_repo, ref_1);
689+
690+
git_project.change_file("Cargo.toml", &basic_manifest("a", "0.2.0"));
691+
git::add(&git_repo);
692+
git::commit(&git_repo);
693+
git::tag(&git_repo, ref_2);
694+
695+
let p = project()
696+
.file(
697+
"Cargo.toml",
698+
&format!(
699+
r#"
700+
[package]
701+
name = "foo"
702+
version = "0.1.0"
703+
704+
[dependencies]
705+
a_1 = {{ package = "a", git = '{url}', rev = '{ref_1}' }}
706+
a_2 = {{ package = "a", git = '{url}', rev = '{ref_2}' }}
707+
"#
708+
),
709+
)
710+
.file("src/lib.rs", "")
711+
.build();
712+
713+
p.cargo("vendor --respect-source-config")
714+
.with_stdout(
715+
r#"[source."git+file://[..]/git?rev=v0.1.0"]
716+
git = [..]
717+
rev = "v0.1.0"
718+
replace-with = "vendored-sources"
719+
720+
[source."git+file://[..]/git?rev=v0.2.0"]
721+
git = [..]
722+
rev = "v0.2.0"
723+
replace-with = "vendored-sources"
724+
725+
[source.vendored-sources]
726+
directory = "vendor"
727+
"#,
728+
)
729+
.run();
730+
}
731+
678732
#[cargo_test]
679733
fn git_duplicate() {
680734
let git = git::new("a", |p| {

0 commit comments

Comments
 (0)