mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
ls: tests for invalid patterns for hide and ignore
This commit is contained in:
parent
fa4272a19b
commit
76308dbec9
2 changed files with 27 additions and 2 deletions
|
@ -449,7 +449,7 @@ impl Config {
|
||||||
for pattern in options.values_of(options::IGNORE).into_iter().flatten() {
|
for pattern in options.values_of(options::IGNORE).into_iter().flatten() {
|
||||||
match glob::Pattern::new(pattern) {
|
match glob::Pattern::new(pattern) {
|
||||||
Ok(p) => ignore_patterns.push(p),
|
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() {
|
for pattern in options.values_of(options::HIDE).into_iter().flatten() {
|
||||||
match glob::Pattern::new(pattern) {
|
match glob::Pattern::new(pattern) {
|
||||||
Ok(p) => ignore_patterns.push(p),
|
Ok(p) => ignore_patterns.push(p),
|
||||||
Err(e) => show_error!("{}", e),
|
Err(_) => show_error!("Invalid pattern for hide: '{}'", pattern),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1288,4 +1288,29 @@ fn test_ls_ignore_hide() {
|
||||||
.arg("*.md")
|
.arg("*.md")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_is("CONTRIBUTING.md\nREADME.md\nREADMECAREFULLY.md\nsome_other_file\n");
|
.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");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue