Skip to content

Commit e458f6d

Browse files
committed
Auto merge of #10047 - jonhoo:ignore-symlink-dir, r=ehuss
Add tests for ignoring symlinks This adds tests for the expected behavior in #10032. Interestingly, these tests pass (🎉). Will update that issue with more details shortly, but figured these tests were worthwhile to add to the testsuite anyway now that I've written them.
2 parents cd46164 + 79cc65f commit e458f6d

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

tests/testsuite/package.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,84 @@ Caused by:
806806
.run();
807807
}
808808

809+
#[cargo_test]
810+
#[cfg(not(windows))] // https://github.com/libgit2/libgit2/issues/6250
811+
/// Test that /dir and /dir/ matches symlinks to directories.
812+
fn gitignore_symlink_dir() {
813+
if !symlink_supported() {
814+
return;
815+
}
816+
817+
let (p, _repo) = git::new_repo("foo", |p| {
818+
p.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
819+
.symlink_dir("src", "src1")
820+
.symlink_dir("src", "src2")
821+
.symlink_dir("src", "src3")
822+
.symlink_dir("src", "src4")
823+
.file(".gitignore", "/src1\n/src2/\nsrc3\nsrc4/")
824+
});
825+
826+
p.cargo("package -l --no-metadata")
827+
.with_stderr("")
828+
.with_stdout(
829+
"\
830+
.cargo_vcs_info.json
831+
.gitignore
832+
Cargo.lock
833+
Cargo.toml
834+
Cargo.toml.orig
835+
src/main.rs
836+
",
837+
)
838+
.run();
839+
}
840+
841+
#[cargo_test]
842+
#[cfg(not(windows))] // https://github.com/libgit2/libgit2/issues/6250
843+
/// Test that /dir and /dir/ matches symlinks to directories in dirty working directory.
844+
fn gitignore_symlink_dir_dirty() {
845+
if !symlink_supported() {
846+
return;
847+
}
848+
849+
let (p, _repo) = git::new_repo("foo", |p| {
850+
p.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
851+
.file(".gitignore", "/src1\n/src2/\nsrc3\nsrc4/")
852+
});
853+
854+
p.symlink("src", "src1");
855+
p.symlink("src", "src2");
856+
p.symlink("src", "src3");
857+
p.symlink("src", "src4");
858+
859+
p.cargo("package -l --no-metadata")
860+
.with_stderr("")
861+
.with_stdout(
862+
"\
863+
.cargo_vcs_info.json
864+
.gitignore
865+
Cargo.lock
866+
Cargo.toml
867+
Cargo.toml.orig
868+
src/main.rs
869+
",
870+
)
871+
.run();
872+
873+
p.cargo("package -l --no-metadata --allow-dirty")
874+
.with_stderr("")
875+
.with_stdout(
876+
"\
877+
.gitignore
878+
Cargo.lock
879+
Cargo.toml
880+
Cargo.toml.orig
881+
src/main.rs
882+
",
883+
)
884+
.run();
885+
}
886+
809887
#[cargo_test]
810888
/// Tests if a symlink to a directory is properly included.
811889
///

0 commit comments

Comments
 (0)