xargs: add more tests and priority

This commit is contained in:
Sylvestre Ledru
2024-04-02 21:00:53 +02:00
parent a123a94c7d
commit 45c1938eef
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -888,7 +888,7 @@ fn do_xargs(args: &[&str]) -> Result<CommandResult, XargsError> {
max_lines: matches.get_one::<usize>(options::MAX_LINES).copied(),
no_run_if_empty: matches.get_flag(options::NO_RUN_IF_EMPTY),
null: matches.get_flag(options::NULL),
replace: [options::REPLACE, options::REPLACE_I]
replace: [options::REPLACE_I, options::REPLACE]
.iter()
.find_map(|&option| {
matches.contains_id(option).then(|| {
+15
View File
@@ -478,6 +478,21 @@ fn xargs_replace() {
.assert()
.stdout(predicate::str::contains("foo bar foo"));
// other order
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-i", "-I=_", "echo", "{} bar {}"])
.write_stdin("foo")
.assert()
.stdout(predicate::str::contains("{} bar {}"));
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-i", "-I", "_", "echo", "{} bar _"])
.write_stdin("foo")
.assert()
.stdout(predicate::str::contains("{} bar foo"));
// Expected to fail
Command::cargo_bin("xargs")
.expect("found binary")