Skip to content

Commit

Permalink
Add tests for ignoring symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Gjengset committed Mar 22, 2022
1 parent cd46164 commit 79cc65f
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 79cc65f

Please sign in to comment.