|
6 | 6 |
|
7 | 7 | use std::fs;
|
8 | 8 |
|
| 9 | +use cargo_test_support::compare::assert_e2e; |
9 | 10 | use cargo_test_support::git;
|
10 | 11 | use cargo_test_support::registry::{self, Package, RegistryBuilder};
|
| 12 | +use cargo_test_support::str; |
11 | 13 | use cargo_test_support::{basic_lib_manifest, basic_manifest, paths, project, Project};
|
12 | 14 |
|
13 | 15 | #[cargo_test]
|
@@ -862,6 +864,128 @@ fn git_complex() {
|
862 | 864 | .run();
|
863 | 865 | }
|
864 | 866 |
|
| 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 | + |
865 | 989 | #[cargo_test]
|
866 | 990 | fn depend_on_vendor_dir_not_deleted() {
|
867 | 991 | let p = project()
|
|
0 commit comments