Test filesystem loop during traversal

Use unordered since order of warning differs on each platform.
This commit is contained in:
Weihang Lo 2021-12-10 19:13:36 +08:00
parent 3591a5bdaf
commit 6fa0f01d87
No known key found for this signature in database
GPG key ID: D7DBF189825E82E7
2 changed files with 27 additions and 4 deletions

View file

@ -4653,7 +4653,7 @@ Caused by:
failed to determine list of files in [..]/foo
Caused by:
cannot read \"[..]/foo/secrets\"
IO error for operation on [..]/foo/secrets: [..]
Caused by:
[..]

View file

@ -794,10 +794,10 @@ fn broken_symlink() {
.with_status(101)
.with_stderr_contains(
"\
error: failed to prepare local package for uploading
error: failed to determine list of files [..]/foo
Caused by:
failed to open for archiving: `[..]foo.rs`
IO error for operation on [..]/foo/src/foo.rs: [..]
Caused by:
[..]
@ -826,6 +826,28 @@ fn package_symlink_to_dir() {
.run();
}
#[cargo_test]
/// Tests if a symlink to ancestor causes filesystem loop error.
///
/// This test requires you to be able to make symlinks.
/// For windows, this may require you to enable developer mode.
fn filesystem_loop() {
if !symlink_supported() {
return;
}
project()
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
.symlink_dir("a/b", "a/b/c/d/foo")
.build()
.cargo("package -v")
.with_status(101)
.with_stderr_contains(
" File system loop found: [..]/a/b/c/d/foo points to an ancestor [..]/a/b",
)
.run();
}
#[cargo_test]
fn do_not_package_if_repository_is_dirty() {
let p = project().build();
@ -1798,7 +1820,8 @@ fn package_restricted_windows() {
.build();
p.cargo("package")
.with_stderr(
// use unordered here because the order of the warning is different on each platform.
.with_stderr_unordered(
"\
[WARNING] file src/aux/mod.rs is a reserved Windows filename, it will not work on Windows platforms
[WARNING] file src/con.rs is a reserved Windows filename, it will not work on Windows platforms