Module assertables::assert_command
source · Expand description
Assert macros for comparing commands and their stdout & stderr.
These macros help with calling external commands, then capturing the standard output stream and standard error stream.
These macros have corresponding the macros in the module assert_program_args.
Compare command standard output string:
-
assert_command_stdout_eq!(command1, command2)≈ command1 stdout = command2 stdout -
assert_command_stdout_eq_expr!(command, expr)≈ command stdout = expr -
assert_command_stdout_contains!(command, containee)≈ command stdout contains containee -
assert_command_stdout_is_match!(command, matcher)≈ command stdout is a matcher match
Compare command standard error string:
-
assert_command_stderr_eq!(command1, command2)≈ command1 stderr = command2 stderr -
assert_command_stderr_eq_expr!(command, expr)≈ command stderr = expr -
assert_command_stderr_contains!(command, containee)≈ command stderr contains containee -
assert_command_stderr_is_match!(command, matcher)≈ command stderr is a matcher match
§Example
use std::process::Command;
let mut a = Command::new("bin/printf-stdout");
a.args(["%s", "hello"]);
let mut b = Command::new("bin/printf-stdout");
b.args(["%s%s%s%s%s", "h", "e", "l", "l", "o"]);
assert_command_stdout_eq!(a, b);Modules§
- Assert a command stderr string contains a given containee.
- Assert a command stderr string is equal to another.
- Assert a command stderr string is equal to an expression.
- Assert a command stderr string is a match to a regex.
- Assert a command stdout string contains a given containee.
- Assert a command stdout string is equal to another.
- Assert a command stdout string is equal to an expression.
- Assert command stdout string is a match to a regex.