mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 09:28:25 +01:00
Add tests for --no-ignore-parent
This commit is contained in:
parent
f8ae334ca9
commit
43f5c8adc9
1 changed files with 72 additions and 0 deletions
|
@ -497,6 +497,78 @@ fn test_gitignore_and_fdignore() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ignore parent ignore files (--no-ignore-parent)
|
||||||
|
#[test]
|
||||||
|
fn test_no_ignore_parent() {
|
||||||
|
let dirs = &["inner"];
|
||||||
|
let files = &[
|
||||||
|
"inner/parent-ignored",
|
||||||
|
"inner/child-ignored",
|
||||||
|
"inner/not-ignored",
|
||||||
|
];
|
||||||
|
let te = TestEnv::new(dirs, files);
|
||||||
|
|
||||||
|
// Ignore 'parent-ignored' in root
|
||||||
|
fs::File::create(te.test_root().join(".gitignore"))
|
||||||
|
.unwrap()
|
||||||
|
.write_all(b"parent-ignored")
|
||||||
|
.unwrap();
|
||||||
|
// Ignore 'child-ignored' in inner
|
||||||
|
fs::File::create(te.test_root().join("inner/.gitignore"))
|
||||||
|
.unwrap()
|
||||||
|
.write_all(b"child-ignored")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
te.assert_output_subdirectory("inner", &[], "not-ignored");
|
||||||
|
|
||||||
|
te.assert_output_subdirectory(
|
||||||
|
"inner",
|
||||||
|
&["--no-ignore-parent"],
|
||||||
|
"parent-ignored
|
||||||
|
not-ignored",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Ignore parent ignore files (--no-ignore-parent) with an inner git repo
|
||||||
|
#[test]
|
||||||
|
fn test_no_ignore_parent_inner_git() {
|
||||||
|
let dirs = &["inner"];
|
||||||
|
let files = &[
|
||||||
|
"inner/parent-ignored",
|
||||||
|
"inner/child-ignored",
|
||||||
|
"inner/not-ignored",
|
||||||
|
];
|
||||||
|
let te = TestEnv::new(dirs, files);
|
||||||
|
|
||||||
|
// Make the inner folder also appear as a git repo
|
||||||
|
fs::create_dir_all(te.test_root().join("inner/.git")).unwrap();
|
||||||
|
|
||||||
|
// Ignore 'parent-ignored' in root
|
||||||
|
fs::File::create(te.test_root().join(".gitignore"))
|
||||||
|
.unwrap()
|
||||||
|
.write_all(b"parent-ignored")
|
||||||
|
.unwrap();
|
||||||
|
// Ignore 'child-ignored' in inner
|
||||||
|
fs::File::create(te.test_root().join("inner/.gitignore"))
|
||||||
|
.unwrap()
|
||||||
|
.write_all(b"child-ignored")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
te.assert_output_subdirectory(
|
||||||
|
"inner",
|
||||||
|
&[],
|
||||||
|
"not-ignored
|
||||||
|
parent-ignored",
|
||||||
|
);
|
||||||
|
|
||||||
|
te.assert_output_subdirectory(
|
||||||
|
"inner",
|
||||||
|
&["--no-ignore-parent"],
|
||||||
|
"not-ignored
|
||||||
|
parent-ignored",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Precedence of .fdignore files
|
/// Precedence of .fdignore files
|
||||||
#[test]
|
#[test]
|
||||||
fn test_custom_ignore_precedence() {
|
fn test_custom_ignore_precedence() {
|
||||||
|
|
Loading…
Reference in a new issue