1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-16 03:36:18 +00:00

Merge pull request #3754 from ackerleytng/main

Add `parse_glob` module and update `du` to use `parse_glob`
This commit is contained in:
Sylvestre Ledru 2022-08-10 19:28:40 +02:00 committed by GitHub
commit 8692301ec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 224 additions and 104 deletions

View file

@ -747,6 +747,40 @@ fn test_du_exclude_mix() {
assert!(result.stdout_str().contains("xcwww"));
}
#[test]
// Disable on Windows because we are looking for /
// And the tests would be more complex if we have to support \ too
#[cfg(not(target_os = "windows"))]
fn test_du_complex_exclude_patterns() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.mkdir_all("azerty/xcwww/azeaze");
at.mkdir_all("azerty/xcwww/qzerty");
at.mkdir_all("azerty/xcwww/amazing");
// Negation in glob should work with both ^ and !
let result = ts
.ucmd()
.arg("--exclude=azerty/*/[^q]*")
.arg("azerty")
.succeeds();
assert!(!result.stdout_str().contains("amazing"));
assert!(result.stdout_str().contains("qzerty"));
assert!(!result.stdout_str().contains("azeaze"));
assert!(result.stdout_str().contains("xcwww"));
let result = ts
.ucmd()
.arg("--exclude=azerty/*/[!q]*")
.arg("azerty")
.succeeds();
assert!(!result.stdout_str().contains("amazing"));
assert!(result.stdout_str().contains("qzerty"));
assert!(!result.stdout_str().contains("azeaze"));
assert!(result.stdout_str().contains("xcwww"));
}
#[test]
fn test_du_exclude_several_components() {
let ts = TestScenario::new(util_name!());