macro_rules! assert_command_stdout_eq_str {
($command:expr, $expect:expr $(,)?) => { ... };
($command:expr, $expect:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a command stdout string is equal to a target string.
-
When true, return
(). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
Examples
use std::process::Command;
let mut a = Command::new("printf");
a.args(["%s", "hello"]);
assert_command_stdout_eq_str!(a, "hello");
//-> ()
let mut a = Command::new("printf");
a.args(["%s", "hello"]);
assert_command_stdout_eq_str!(a, "world");
//-> panic!("…")
// assertion failed: `assert_command_stdout_eq_str!(command, expect)`
// command program: `\"printf\"`,
// stdout: `\"hello\"`,
// expect: `\"world\"`This macro has a second form where a custom message can be provided.