1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

ls: tests for invalid patterns for hide and ignore

This commit is contained in:
Terts Diepraam 2021-04-04 22:35:22 +02:00
parent fa4272a19b
commit 76308dbec9
2 changed files with 27 additions and 2 deletions

View file

@ -449,7 +449,7 @@ impl Config {
for pattern in options.values_of(options::IGNORE).into_iter().flatten() {
match glob::Pattern::new(pattern) {
Ok(p) => ignore_patterns.push(p),
Err(e) => show_error!("{}", e),
Err(_) => show_error!("Invalid pattern for ignore: '{}'", pattern),
}
}
@ -457,7 +457,7 @@ impl Config {
for pattern in options.values_of(options::HIDE).into_iter().flatten() {
match glob::Pattern::new(pattern) {
Ok(p) => ignore_patterns.push(p),
Err(e) => show_error!("{}", e),
Err(_) => show_error!("Invalid pattern for hide: '{}'", pattern),
}
}
}

View file

@ -1288,4 +1288,29 @@ fn test_ls_ignore_hide() {
.arg("*.md")
.succeeds()
.stdout_is("CONTRIBUTING.md\nREADME.md\nREADMECAREFULLY.md\nsome_other_file\n");
// Stacking multiple patterns
scene
.ucmd()
.arg("--ignore")
.arg("README*")
.arg("--ignore")
.arg("CONTRIBUTING*")
.succeeds()
.stdout_is("some_other_file\n");
// Invalid patterns
scene
.ucmd()
.arg("--ignore")
.arg("READ[ME")
.succeeds()
.stderr_contains(&"Invalid pattern");
scene
.ucmd()
.arg("--ignore")
.arg("READ[ME")
.succeeds()
.stderr_contains(&"Invalid pattern");
}