Skip to content

Commit 6fa0f01

Browse files
committed
Test filesystem loop during traversal
Use unordered since order of warning differs on each platform.
1 parent 3591a5b commit 6fa0f01

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

tests/testsuite/build_script.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4653,7 +4653,7 @@ Caused by:
46534653
failed to determine list of files in [..]/foo
46544654
46554655
Caused by:
4656-
cannot read \"[..]/foo/secrets\"
4656+
IO error for operation on [..]/foo/secrets: [..]
46574657
46584658
Caused by:
46594659
[..]

tests/testsuite/package.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,10 +794,10 @@ fn broken_symlink() {
794794
.with_status(101)
795795
.with_stderr_contains(
796796
"\
797-
error: failed to prepare local package for uploading
797+
error: failed to determine list of files [..]/foo
798798
799799
Caused by:
800-
failed to open for archiving: `[..]foo.rs`
800+
IO error for operation on [..]/foo/src/foo.rs: [..]
801801
802802
Caused by:
803803
[..]
@@ -826,6 +826,28 @@ fn package_symlink_to_dir() {
826826
.run();
827827
}
828828

829+
#[cargo_test]
830+
/// Tests if a symlink to ancestor causes filesystem loop error.
831+
///
832+
/// This test requires you to be able to make symlinks.
833+
/// For windows, this may require you to enable developer mode.
834+
fn filesystem_loop() {
835+
if !symlink_supported() {
836+
return;
837+
}
838+
839+
project()
840+
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
841+
.symlink_dir("a/b", "a/b/c/d/foo")
842+
.build()
843+
.cargo("package -v")
844+
.with_status(101)
845+
.with_stderr_contains(
846+
" File system loop found: [..]/a/b/c/d/foo points to an ancestor [..]/a/b",
847+
)
848+
.run();
849+
}
850+
829851
#[cargo_test]
830852
fn do_not_package_if_repository_is_dirty() {
831853
let p = project().build();
@@ -1798,7 +1820,8 @@ fn package_restricted_windows() {
17981820
.build();
17991821

18001822
p.cargo("package")
1801-
.with_stderr(
1823+
// use unordered here because the order of the warning is different on each platform.
1824+
.with_stderr_unordered(
18021825
"\
18031826
[WARNING] file src/aux/mod.rs is a reserved Windows filename, it will not work on Windows platforms
18041827
[WARNING] file src/con.rs is a reserved Windows filename, it will not work on Windows platforms

0 commit comments

Comments
 (0)