Skip to content

Commit 7a05add

Browse files
committed
test(vendor): Ensure order is consistent
1 parent a82dfd6 commit 7a05add

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

tests/testsuite/vendor.rs

Lines changed: 124 additions & 0 deletions
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,128 @@ 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(git_dep_manifest, str![[r##"
928+
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
929+
#
930+
# When uploading crates to the registry Cargo will automatically
931+
# "normalize" Cargo.toml files for maximal compatibility
932+
# with all versions of Cargo and also rewrite `path` dependencies
933+
# to registry (e.g., crates.io) dependencies.
934+
#
935+
# If you are reading this file be aware that the original Cargo.toml
936+
# will likely look very different (and much more reasonable).
937+
# See Cargo.toml.orig for the original contents.
938+
939+
bin = []
940+
test = []
941+
bench = []
942+
943+
[package]
944+
edition = "2021"
945+
name = "git_dep"
946+
version = "0.0.1"
947+
authors = []
948+
build = false
949+
autobins = false
950+
autoexamples = false
951+
autotests = false
952+
autobenches = false
953+
description = "foo"
954+
documentation = "docs.rs/foo"
955+
readme = false
956+
license = "MIT"
957+
958+
[lib]
959+
name = "git_dep"
960+
path = "src/lib.rs"
961+
962+
[[example]]
963+
name = "c"
964+
path = "examples/c.rs"
965+
966+
[[example]]
967+
name = "b"
968+
path = "examples/b.rs"
969+
970+
[[example]]
971+
name = "a"
972+
path = "examples/a.rs"
973+
974+
[[example]]
975+
name = "z"
976+
path = "examples/z.rs"
977+
978+
[[example]]
979+
name = "x"
980+
path = "examples/x.rs"
981+
982+
[[example]]
983+
name = "y"
984+
path = "examples/y.rs"
985+
986+
"##]]);
987+
}
988+
865989
#[cargo_test]
866990
fn depend_on_vendor_dir_not_deleted() {
867991
let p = project()

0 commit comments

Comments
 (0)