Skip to content

Commit

Permalink
Add tests for crates windows reserved filenames
Browse files Browse the repository at this point in the history
Following rust-lang#8055 we need to propperly print errors if the
path to any file of the package contains a windows reserved filename.

- Added tests for packages with a file that has a reserved filename on
Windows.

- Added tests for packages with a folder that has a reserved
filaname on Windows.
  • Loading branch information
CPerezz committed Apr 26, 2020
1 parent 6de1724 commit 7e2e3e8
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1458,3 +1458,65 @@ fn git_install_reads_workspace_manifest() {
.with_stderr_contains(" invalid type: integer `3`[..]")
.run();
}

#[cfg(target_os = "windows")]
#[cargo_test]
fn has_file_with_windows_reserved_filenames() {
Package::new("foo", "0.0.1")
.file("src/lib.rs", "pub mod aux;")
.file(
"src/aux.rs",
"//! This file has a windows reserved filename.",
)
.file("src/main.rs", &format!("extern crate foo; fn main() {{}}"))
.publish();

cargo_process("install foo")
.with_status(101)
.with_stderr(
"\
[UPDATING] `[..]` index
[DOWNLOADING] crates ...
[DOWNLOADED] foo v0.0.1 (registry [..])
error: failed to download replaced source registry [..]\n
Caused by:
failed to unpack package `foo v0.0.1 (registry [..])`
Caused by:
failed to unpack entry at `foo-0.0.1/src/aux.rs`.
The package cointains the file \"aux.rs\" which has in it's path a filename that uses Windows reserved filenames",
)
.run();
assert_has_not_installed_exe(cargo_home(), "foo");
}

#[cfg(target_os = "windows")]
#[cargo_test]
fn has_folder_with_windows_reserved_filenames() {
Package::new("foo", "0.0.1")
.file("src/lib.rs", "pub mod aux;")
.file("src/main.rs", &format!("extern crate foo; fn main() {{}}"))
.file(
"src/aux/mod.rs",
"//! File in a folder with reserved filename!",
)
.publish();

cargo_process("install foo")
.with_status(101)
.with_stderr(
"\
[UPDATING] `[..]` index
[DOWNLOADING] crates ...
[DOWNLOADED] foo v0.0.1 (registry [..])
error: failed to download replaced source registry [..]\n
Caused by:
failed to unpack package `foo v0.0.1 (registry [..])`
Caused by:
failed to unpack entry at `foo-0.0.1/src/aux/mod.rs`.
The package cointains the file \"mod.rs\" which has in it's path a filename that uses Windows reserved filenames",
)
.run();
assert_has_not_installed_exe(cargo_home(), "foo");
}

0 comments on commit 7e2e3e8

Please sign in to comment.