Skip to content

Commit d5938cc

Browse files
committed
test(vendor): Ensure order is consistent
1 parent 227a102 commit d5938cc

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

tests/testsuite/vendor.rs

+127
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
77
use std::fs;
88

9+
use cargo_test_support::compare::assert_e2e;
910
use cargo_test_support::git;
1011
use cargo_test_support::registry::{self, Package, RegistryBuilder};
12+
use cargo_test_support::str;
1113
use cargo_test_support::{basic_lib_manifest, basic_manifest, paths, project, Project};
1214

1315
#[cargo_test]
@@ -862,6 +864,131 @@ fn git_complex() {
862864
.run();
863865
}
864866

867+
#[cargo_test]
868+
fn git_deterministic() {
869+
let git_dep = git::new("git_dep", |p| {
870+
p.file(
871+
"Cargo.toml",
872+
r#"
873+
[package]
874+
name = "git_dep"
875+
version = "0.0.1"
876+
edition = "2021"
877+
license = "MIT"
878+
description = "foo"
879+
documentation = "docs.rs/foo"
880+
authors = []
881+
882+
[[example]]
883+
name = "c"
884+
885+
[[example]]
886+
name = "b"
887+
888+
[[example]]
889+
name = "a"
890+
"#,
891+
)
892+
.file("src/lib.rs", "")
893+
.file("examples/z.rs", "fn main() {}")
894+
.file("examples/y.rs", "fn main() {}")
895+
.file("examples/x.rs", "fn main() {}")
896+
.file("examples/c.rs", "fn main() {}")
897+
.file("examples/b.rs", "fn main() {}")
898+
.file("examples/a.rs", "fn main() {}")
899+
});
900+
901+
let p = project()
902+
.file(
903+
"Cargo.toml",
904+
&format!(
905+
r#"
906+
[package]
907+
name = "foo"
908+
version = "0.1.0"
909+
910+
[dependencies]
911+
git_dep = {{ git = '{}' }}
912+
"#,
913+
git_dep.url()
914+
),
915+
)
916+
.file("src/lib.rs", "")
917+
.build();
918+
919+
let output = p
920+
.cargo("vendor --respect-source-config")
921+
.exec_with_output()
922+
.unwrap();
923+
let output = String::from_utf8(output.stdout).unwrap();
924+
p.change_file(".cargo/config.toml", &output);
925+
926+
let git_dep_manifest = p.read_file("vendor/git_dep/Cargo.toml");
927+
assert_e2e().eq(
928+
git_dep_manifest,
929+
str![[r##"
930+
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
931+
#
932+
# When uploading crates to the registry Cargo will automatically
933+
# "normalize" Cargo.toml files for maximal compatibility
934+
# with all versions of Cargo and also rewrite `path` dependencies
935+
# to registry (e.g., crates.io) dependencies.
936+
#
937+
# If you are reading this file be aware that the original Cargo.toml
938+
# will likely look very different (and much more reasonable).
939+
# See Cargo.toml.orig for the original contents.
940+
941+
bin = []
942+
test = []
943+
bench = []
944+
945+
[package]
946+
edition = "2021"
947+
name = "git_dep"
948+
version = "0.0.1"
949+
authors = []
950+
build = false
951+
autobins = false
952+
autoexamples = false
953+
autotests = false
954+
autobenches = false
955+
description = "foo"
956+
documentation = "docs.rs/foo"
957+
readme = false
958+
license = "MIT"
959+
960+
[lib]
961+
name = "git_dep"
962+
path = [..]
963+
964+
[[example]]
965+
name = "c"
966+
path = [..]
967+
968+
[[example]]
969+
name = "b"
970+
path = [..]
971+
972+
[[example]]
973+
name = "a"
974+
path = [..]
975+
976+
[[example]]
977+
name = "z"
978+
path = [..]
979+
980+
[[example]]
981+
name = "x"
982+
path = [..]
983+
984+
[[example]]
985+
name = "y"
986+
path = [..]
987+
988+
"##]],
989+
);
990+
}
991+
865992
#[cargo_test]
866993
fn depend_on_vendor_dir_not_deleted() {
867994
let p = project()

0 commit comments

Comments
 (0)