macro_rules! assertable_command_stdout_eq_str {
($command:expr, $str:expr $(,)?) => { ... };
($command:expr, $str:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a command stdout string is equal to a given string.
-
When true, return
Ok(()). -
Otherwise, return
Errwith 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"]);
let str = "hello";
let x = assertable_command_stdout_eq_str!(a, str);
//-> Ok(())
assert_eq!(x.unwrap(), ());
let mut a = Command::new("printf");
a.args(["%s", "hello"]);
let str = "world";
let x = assertable_command_stdout_eq_str!(a, str);
//-> Err!("…")
// assertable failed: `assertable_command_stdout_eq_str!(command, str)`
// command program: `\"printf\"`,
// stdout: `\"hello\"`,
// expect: `\"world\"`This macro has a second form where a custom message can be provided.