Skip to content

Commit 81b1bb1

Browse files
committed
test(package): Ensure order is consistent
1 parent 8114c9a commit 81b1bb1

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

tests/testsuite/package.rs

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4928,3 +4928,126 @@ path = "src/lib.rs"
49284928
)],
49294929
);
49304930
}
4931+
4932+
#[cargo_test]
4933+
fn deterministic_build_targets() {
4934+
let p = project()
4935+
.file(
4936+
"Cargo.toml",
4937+
r#"
4938+
[package]
4939+
name = "foo"
4940+
version = "0.0.1"
4941+
edition = "2021"
4942+
license = "MIT"
4943+
description = "foo"
4944+
documentation = "docs.rs/foo"
4945+
authors = []
4946+
4947+
[[example]]
4948+
name = "c"
4949+
4950+
[[example]]
4951+
name = "b"
4952+
4953+
[[example]]
4954+
name = "a"
4955+
"#,
4956+
)
4957+
.file("src/lib.rs", "")
4958+
.file("examples/z.rs", "fn main() {}")
4959+
.file("examples/y.rs", "fn main() {}")
4960+
.file("examples/x.rs", "fn main() {}")
4961+
.file("examples/c.rs", "fn main() {}")
4962+
.file("examples/b.rs", "fn main() {}")
4963+
.file("examples/a.rs", "fn main() {}")
4964+
.build();
4965+
4966+
p.cargo("package")
4967+
.with_stdout("")
4968+
.with_stderr(
4969+
"\
4970+
[PACKAGING] foo v0.0.1 ([CWD])
4971+
[VERIFYING] foo v0.0.1 ([CWD])
4972+
[COMPILING] foo v0.0.1 ([CWD][..])
4973+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
4974+
[PACKAGED] 10 files, [..] ([..] compressed)
4975+
",
4976+
)
4977+
.run();
4978+
4979+
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
4980+
validate_crate_contents(
4981+
f,
4982+
"foo-0.0.1.crate",
4983+
&[
4984+
"Cargo.lock",
4985+
"Cargo.toml",
4986+
"Cargo.toml.orig",
4987+
"src/lib.rs",
4988+
"examples/a.rs",
4989+
"examples/b.rs",
4990+
"examples/c.rs",
4991+
"examples/x.rs",
4992+
"examples/y.rs",
4993+
"examples/z.rs",
4994+
],
4995+
&[(
4996+
"Cargo.toml",
4997+
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
4998+
#
4999+
# When uploading crates to the registry Cargo will automatically
5000+
# "normalize" Cargo.toml files for maximal compatibility
5001+
# with all versions of Cargo and also rewrite `path` dependencies
5002+
# to registry (e.g., crates.io) dependencies.
5003+
#
5004+
# If you are reading this file be aware that the original Cargo.toml
5005+
# will likely look very different (and much more reasonable).
5006+
# See Cargo.toml.orig for the original contents.
5007+
5008+
[package]
5009+
edition = "2021"
5010+
name = "foo"
5011+
version = "0.0.1"
5012+
authors = []
5013+
build = false
5014+
autobins = false
5015+
autoexamples = false
5016+
autotests = false
5017+
autobenches = false
5018+
description = "foo"
5019+
documentation = "docs.rs/foo"
5020+
readme = false
5021+
license = "MIT"
5022+
5023+
[lib]
5024+
name = "foo"
5025+
path = "src/lib.rs"
5026+
5027+
[[example]]
5028+
name = "a"
5029+
path = "examples/a.rs"
5030+
5031+
[[example]]
5032+
name = "b"
5033+
path = "examples/b.rs"
5034+
5035+
[[example]]
5036+
name = "c"
5037+
path = "examples/c.rs"
5038+
5039+
[[example]]
5040+
name = "x"
5041+
path = "examples/x.rs"
5042+
5043+
[[example]]
5044+
name = "y"
5045+
path = "examples/y.rs"
5046+
5047+
[[example]]
5048+
name = "z"
5049+
path = "examples/z.rs"
5050+
"#,
5051+
)],
5052+
);
5053+
}

0 commit comments

Comments
 (0)