Skip to content

Commit

Permalink
Auto merge of #10047 - jonhoo:ignore-symlink-dir, r=ehuss
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Mar 23, 2022
2 parents cd46164 + 79cc65f commit e458f6d
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,84 @@ Caused by:
.run();
}

#[cargo_test]
#[cfg(not(windows))] // https://github.com/libgit2/libgit2/issues/6250
/// Test that /dir and /dir/ matches symlinks to directories.
fn gitignore_symlink_dir() {
if !symlink_supported() {
return;
}

let (p, _repo) = git::new_repo("foo", |p| {
p.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
.symlink_dir("src", "src1")
.symlink_dir("src", "src2")
.symlink_dir("src", "src3")
.symlink_dir("src", "src4")
.file(".gitignore", "/src1\n/src2/\nsrc3\nsrc4/")
});

p.cargo("package -l --no-metadata")
.with_stderr("")
.with_stdout(
"\
.cargo_vcs_info.json
.gitignore
Cargo.lock
Cargo.toml
Cargo.toml.orig
src/main.rs
",
)
.run();
}

#[cargo_test]
#[cfg(not(windows))] // https://github.com/libgit2/libgit2/issues/6250
/// Test that /dir and /dir/ matches symlinks to directories in dirty working directory.
fn gitignore_symlink_dir_dirty() {
if !symlink_supported() {
return;
}

let (p, _repo) = git::new_repo("foo", |p| {
p.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
.file(".gitignore", "/src1\n/src2/\nsrc3\nsrc4/")
});

p.symlink("src", "src1");
p.symlink("src", "src2");
p.symlink("src", "src3");
p.symlink("src", "src4");

p.cargo("package -l --no-metadata")
.with_stderr("")
.with_stdout(
"\
.cargo_vcs_info.json
.gitignore
Cargo.lock
Cargo.toml
Cargo.toml.orig
src/main.rs
",
)
.run();

p.cargo("package -l --no-metadata --allow-dirty")
.with_stderr("")
.with_stdout(
"\
.gitignore
Cargo.lock
Cargo.toml
Cargo.toml.orig
src/main.rs
",
)
.run();
}

#[cargo_test]
/// Tests if a symlink to a directory is properly included.
///
Expand Down

0 comments on commit e458f6d

Please sign in to comment.