Skip to content

Commit

Permalink
test(vendor): Ensure order is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jun 3, 2024
1 parent a82dfd6 commit 6e346a2
Showing 1 changed file with 127 additions and 0 deletions.
127 changes: 127 additions & 0 deletions tests/testsuite/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
use std::fs;

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

#[cargo_test]
Expand Down Expand Up @@ -862,6 +864,131 @@ fn git_complex() {
.run();
}

#[cargo_test]
fn git_deterministic() {
let git_dep = git::new("git_dep", |p| {
p.file(
"Cargo.toml",
r#"
[package]
name = "git_dep"
version = "0.0.1"
edition = "2021"
license = "MIT"
description = "foo"
documentation = "docs.rs/foo"
authors = []
[[example]]
name = "c"
[[example]]
name = "b"
[[example]]
name = "a"
"#,
)
.file("src/lib.rs", "")
.file("examples/z.rs", "fn main() {}")
.file("examples/y.rs", "fn main() {}")
.file("examples/x.rs", "fn main() {}")
.file("examples/c.rs", "fn main() {}")
.file("examples/b.rs", "fn main() {}")
.file("examples/a.rs", "fn main() {}")
});

let p = project()
.file(
"Cargo.toml",
&format!(
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
git_dep = {{ git = '{}' }}
"#,
git_dep.url()
),
)
.file("src/lib.rs", "")
.build();

let output = p
.cargo("vendor --respect-source-config")
.exec_with_output()
.unwrap();
let output = String::from_utf8(output.stdout).unwrap();
p.change_file(".cargo/config.toml", &output);

let git_dep_manifest = p.read_file("vendor/git_dep/Cargo.toml");
assert_e2e().eq(
git_dep_manifest,
str![[r##"
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
bin = []
test = []
bench = []
[package]
edition = "2021"
name = "git_dep"
version = "0.0.1"
authors = []
build = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "foo"
documentation = "docs.rs/foo"
readme = false
license = "MIT"
[lib]
name = "git_dep"
path = [..]
[[example]]
name = "c"
path = [..]
[[example]]
name = "b"
path = [..]
[[example]]
name = "a"
path = [..]
[[example]]
name = "z"
path = [..]
[[example]]
name = "x"
path = [..]
[[example]]
name = "y"
path = [..]
"##]],
);
}

#[cargo_test]
fn depend_on_vendor_dir_not_deleted() {
let p = project()
Expand Down

0 comments on commit 6e346a2

Please sign in to comment.