Skip to content

Commit

Permalink
added some tests to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jellehelsen committed Aug 13, 2023
1 parent d7c62ed commit 6068512
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/xargs_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,63 @@ fn xargs_exec_not_found() {
.stderr(predicate::str::contains("Error:"))
.stdout(predicate::str::is_empty());
}

#[test]
fn xargs_exec_verbose() {
Command::cargo_bin("xargs")
.expect("found binary")
.args([
"-n2",
"--verbose",
&path_to_testing_commandline(),
"-",
"--print_stdin",
"--no_print_cwd",
])
.write_stdin("a b c\nd")
.assert()
.success()
.stderr(predicate::str::contains("testing-commandline"))
.stdout(predicate::str::diff(
"stdin=\nargs=\n--print_stdin\n--no_print_cwd\na\nb\n\
stdin=\nargs=\n--print_stdin\n--no_print_cwd\nc\nd\n",
));
}

#[test]
fn xargs_unterminated_quote() {
Command::cargo_bin("xargs")
.expect("found binary")
.args([
"-n2",
&path_to_testing_commandline(),
"-",
"--print_stdin",
"--no_print_cwd",
])
.write_stdin("a \"b c\nd")
.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Error: Unterminated quote:"))
.stdout(predicate::str::is_empty());
}

#[test]
fn xargs_zero_lines() {
Command::cargo_bin("xargs")
.expect("found binary")
.args([
"-L0",
&path_to_testing_commandline(),
"-",
"--print_stdin",
"--no_print_cwd",
])
.write_stdin("a \"b c\nd")
.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Value must be > 0, not: 0"))
.stdout(predicate::str::is_empty());
}

0 comments on commit 6068512

Please sign in to comment.