test(package): Show behavior with backslashes

This commit is contained in:
Ed Page 2024-04-09 13:44:25 -05:00
parent bd1cf584af
commit 4eea907733
1 changed files with 125 additions and 0 deletions

View File

@ -3541,3 +3541,128 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
)
.run()
}
#[cargo_test]
#[cfg(windows)]
fn normalize_paths() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
edition = "2015"
description = "foo"
documentation = "docs.rs/foo"
authors = []
readme = ".\\docs\\README.md"
license-file = ".\\docs\\LICENSE"
build = ".\\src\\build.rs"
[lib]
path = ".\\src\\lib.rs"
[[bin]]
name = "foo"
path = ".\\src\\bin\\foo\\main.rs"
[[example]]
name = "example_foo"
path = ".\\examples\\example_foo.rs"
[[test]]
name = "test_foo"
path = ".\\tests\\test_foo.rs"
[[bench]]
name = "bench_foo"
path = ".\\benches\\bench_foo.rs"
"#,
)
.file("src/lib.rs", "")
.file("docs/README.md", "")
.file("docs/LICENSE", "")
.file("src/build.rs", "fn main() {}")
.file("src/bin/foo/main.rs", "fn main() {}")
.file("examples/example_foo.rs", "fn main() {}")
.file("tests/test_foo.rs", "fn main() {}")
.file("benches/bench_foo.rs", "fn main() {}")
.build();
p.cargo("package")
.with_stdout("")
.with_stderr(
"\
[PACKAGING] foo v0.0.1 ([CWD])
[VERIFYING] foo v0.0.1 ([CWD])
[COMPILING] foo v0.0.1 ([CWD][..])
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
[PACKAGED] 11 files, [..] ([..] compressed)
",
)
.run();
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
validate_crate_contents(
f,
"foo-0.0.1.crate",
&[
"Cargo.lock",
"Cargo.toml",
"Cargo.toml.orig",
"src/lib.rs",
"docs/README.md",
"docs/LICENSE",
"src/build.rs",
"src/bin/foo/main.rs",
"examples/example_foo.rs",
"tests/test_foo.rs",
"benches/bench_foo.rs",
],
&[(
"Cargo.toml",
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.
[package]
edition = "2015"
name = "foo"
version = "0.0.1"
authors = []
build = './src/build.rs'
description = "foo"
documentation = "docs.rs/foo"
readme = './docs/README.md'
license-file = './docs/LICENSE'
[lib]
path = './src/lib.rs'
[[bin]]
name = "foo"
path = './src/bin/foo/main.rs'
[[example]]
name = "example_foo"
path = './examples/example_foo.rs'
[[test]]
name = "test_foo"
path = './tests/test_foo.rs'
[[bench]]
name = "bench_foo"
path = './benches/bench_foo.rs'
"#,
)],
);
}