1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge pull request #2026 from tertsdiepraam/ls/hide_and_ignore

ls: --hide and --ignore
This commit is contained in:
Sylvestre Ledru 2021-04-05 22:31:23 +02:00 committed by GitHub
commit 7cdeb18dff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 214 additions and 10 deletions

View file

@ -1245,3 +1245,146 @@ fn test_ls_quoting_style() {
assert_eq!(result.stdout, format!("{}\n", correct));
}
}
#[test]
fn test_ls_ignore_hide() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("README.md");
at.touch("CONTRIBUTING.md");
at.touch("some_other_file");
at.touch("READMECAREFULLY.md");
scene
.ucmd()
.arg("--hide")
.arg("*")
.arg("-1")
.succeeds()
.stdout_is("");
scene
.ucmd()
.arg("--ignore")
.arg("*")
.arg("-1")
.succeeds()
.stdout_is("");
scene
.ucmd()
.arg("--ignore")
.arg("irrelevant pattern")
.arg("-1")
.succeeds()
.stdout_is("CONTRIBUTING.md\nREADME.md\nREADMECAREFULLY.md\nsome_other_file\n");
scene
.ucmd()
.arg("--ignore")
.arg("README*.md")
.arg("-1")
.succeeds()
.stdout_is("CONTRIBUTING.md\nsome_other_file\n");
scene
.ucmd()
.arg("--hide")
.arg("README*.md")
.arg("-1")
.succeeds()
.stdout_is("CONTRIBUTING.md\nsome_other_file\n");
scene
.ucmd()
.arg("--ignore")
.arg("*.md")
.arg("-1")
.succeeds()
.stdout_is("some_other_file\n");
scene
.ucmd()
.arg("-a")
.arg("--ignore")
.arg("*.md")
.arg("-1")
.succeeds()
.stdout_is(".\n..\nsome_other_file\n");
scene
.ucmd()
.arg("-a")
.arg("--hide")
.arg("*.md")
.arg("-1")
.succeeds()
.stdout_is(".\n..\nCONTRIBUTING.md\nREADME.md\nREADMECAREFULLY.md\nsome_other_file\n");
scene
.ucmd()
.arg("-A")
.arg("--ignore")
.arg("*.md")
.arg("-1")
.succeeds()
.stdout_is("some_other_file\n");
scene
.ucmd()
.arg("-A")
.arg("--hide")
.arg("*.md")
.arg("-1")
.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*")
.arg("-1")
.succeeds()
.stdout_is("some_other_file\n");
scene
.ucmd()
.arg("--hide")
.arg("README*")
.arg("--ignore")
.arg("CONTRIBUTING*")
.arg("-1")
.succeeds()
.stdout_is("some_other_file\n");
scene
.ucmd()
.arg("--hide")
.arg("README*")
.arg("--hide")
.arg("CONTRIBUTING*")
.arg("-1")
.succeeds()
.stdout_is("some_other_file\n");
// Invalid patterns
scene
.ucmd()
.arg("--ignore")
.arg("READ[ME")
.arg("-1")
.succeeds()
.stderr_contains(&"Invalid pattern");
scene
.ucmd()
.arg("--hide")
.arg("READ[ME")
.arg("-1")
.succeeds()
.stderr_contains(&"Invalid pattern");
}