Skip to content

Commit 52a418c

Browse files
committed
test: ignore broken but excluded file during traversing
1 parent 09ff194 commit 52a418c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/testsuite/package.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,55 @@ Caused by:
845845
.run();
846846
}
847847

848+
#[cargo_test]
849+
/// Tests if a broken but excluded symlink is ignored.
850+
/// See issue rust-lang/cargo#10917
851+
///
852+
/// This test requires you to be able to make symlinks.
853+
/// For windows, this may require you to enable developer mode.
854+
fn broken_but_excluded_symlink() {
855+
#[cfg(unix)]
856+
use std::os::unix::fs::symlink;
857+
#[cfg(windows)]
858+
use std::os::windows::fs::symlink_dir as symlink;
859+
860+
if !symlink_supported() {
861+
return;
862+
}
863+
864+
let p = project()
865+
.file(
866+
"Cargo.toml",
867+
r#"
868+
[project]
869+
name = "foo"
870+
version = "0.0.1"
871+
authors = []
872+
license = "MIT"
873+
description = 'foo'
874+
documentation = 'foo'
875+
homepage = 'foo'
876+
repository = 'foo'
877+
exclude = ["src/foo.rs"]
878+
"#,
879+
)
880+
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
881+
.build();
882+
t!(symlink("nowhere", &p.root().join("src/foo.rs")));
883+
884+
p.cargo("package -v --list")
885+
// `src/foo.rs` is excluded.
886+
.with_stdout(
887+
"\
888+
Cargo.lock
889+
Cargo.toml
890+
Cargo.toml.orig
891+
src/main.rs
892+
",
893+
)
894+
.run();
895+
}
896+
848897
#[cargo_test]
849898
#[cfg(not(windows))] // https://github.com/libgit2/libgit2/issues/6250
850899
/// Test that /dir and /dir/ matches symlinks to directories.

0 commit comments

Comments
 (0)