macro_rules! assertable_command_stderr_eq {
($left_command:expr, $right_command:expr $(,)?) => { ... };
($left_command:expr, $right_command:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a command stderr 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");
let mut b = Command::new("printf");
let x = assertable_command_stderr_eq!(a, b);
//-> Ok(())
assert_eq!(x.unwrap(), ());
let mut a = Command::new("printf");
let mut b = Command::new("printf");
b.arg("-v");
let x = assertable_command_stderr_eq!(a, b);
//-> Err("…")
// assertable failed: `assertable_command_stderr_eq!(left_command, right_command)`
// left command program: `\"printf\"`,
// right command program: `\"printf\"`,
// left stderr: `\"usage: printf format [arguments ...]\\n\"`,
// right stderr: `\"printf: illegal option -- v\\nusage: printf format [arguments ...]\\n\"`
assert_eq!(x.unwrap_err(), "assertable failed: `assertable_command_stderr_eq!(left_command, right_command)`\n left command program: `\"printf\"`,\n right command program: `\"printf\"`,\n left stderr: `\"usage: printf format [arguments ...]\\n\"`,\n right stderr: `\"printf: illegal option -- v\\nusage: printf format [arguments ...]\\n\"`");This macro has a second form where a custom message can be provided.