mirror of
https://github.com/uutils/findutils.git
synced 2026-06-10 15:48:30 -07:00
find: use GNU wording "unknown predicate" for unrecognized args
GNU find rejects an unrecognized predicate with "find: unknown predicate '<arg>'", but we printed "find: Unrecognized flag: '<arg>'". Match GNU so the tests/find/refuse-noop GNU test (and others hitting the same path) pass. Add an integration test covering -noop and ---noop.
This commit is contained in:
@@ -975,7 +975,7 @@ fn build_matcher_tree(
|
||||
)
|
||||
}
|
||||
}
|
||||
None => return Err(From::from(format!("Unrecognized flag: '{}'", args[i]))),
|
||||
None => return Err(From::from(format!("unknown predicate '{}'", args[i]))),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -546,7 +546,7 @@ mod tests {
|
||||
//
|
||||
let result = super::parse_args(&["-asdadsafsfsadcs"]);
|
||||
if let Err(e) = result {
|
||||
assert_eq!(e.to_string(), "Unrecognized flag: '-asdadsafsfsadcs'");
|
||||
assert_eq!(e.to_string(), "unknown predicate '-asdadsafsfsadcs'");
|
||||
} else {
|
||||
panic!("parse_args should have returned an error");
|
||||
}
|
||||
|
||||
@@ -82,6 +82,24 @@ fn multiple_matcher_success() {
|
||||
.stdout_contains("abbbc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_predicate_is_rejected() {
|
||||
// GNU find rejects an unrecognized predicate with
|
||||
// "find: unknown predicate '<arg>'" and exit code 1 (see the GNU
|
||||
// testsuite's tests/find/refuse-noop test).
|
||||
ucmd()
|
||||
.arg("-noop")
|
||||
.fails()
|
||||
.stderr_contains("unknown predicate '-noop'")
|
||||
.no_stdout();
|
||||
|
||||
ucmd()
|
||||
.arg("---noop")
|
||||
.fails()
|
||||
.stderr_contains("unknown predicate '---noop'")
|
||||
.no_stdout();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiple_matcher_failure() {
|
||||
ucmd()
|
||||
|
||||
Reference in New Issue
Block a user