macro_rules! assertable_command_stdout_eq {
($left_command:expr, $right_command:expr $(,)?) => { ... };
($left_command:expr, $right_command:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a command stdout string is equal to another.
-
When true, return
(). -
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 mut b = Command::new("printf");
b.args(["%s%s%s%s%s", "h", "e", "l", "l", "o"]);
let x = assertable_command_stdout_eq!(a, b);
//-> Ok(())
assert_eq!(x.unwrap(), ());
let mut a = Command::new("printf");
a.args(["%s", "hello"]);
let mut b = Command::new("printf");
b.args(["%s%s%s%s%s", "w", "o", "r", "l", "d"]);
let x = assertable_command_stdout_eq!(a, b);
//-> Err("…")
// assertable failed: `assertable_command_stdout_eq!(left_command, right_command)`
// left command program: `\"printf\"`,
// right command program: `\"printf\"`,
// left stdout: `\"hello\"`,
// right stdout: `\"world\"`
assert_eq!(x.unwrap_err(), "assertable failed: `assertable_command_stdout_eq!(left_command, right_command)`\n left command program: `\"printf\"`,\n right command program: `\"printf\"`,\n left stdout: `\"hello\"`,\n right stdout: `\"world\"`");This macro has a second form where a custom message can be provided.