macro_rules! assert_command_stderr_eq {
    ($a_command:expr, $b_expr:expr $(,)?) => { ... };
    ($a_command:expr, $b_expr:expr, $($arg:tt)+) => { ... };
}
Expand description

Assert a command stderr string is equal to an expression.

  • If 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 command = Command::new("printf");
let s = "usage: printf format [arguments ...]\n";
assert_command_stderr_eq!(command, s);
//-> ()

let result = panic::catch_unwind(|| {
let mut command = Command::new("printf");
let s = "hello";
assert_command_stderr_eq!(command, s);
//-> panic!
});
let actual = result.unwrap_err().downcast::<String>().unwrap().to_string();
let expect = concat!(
    "assertion failed: `assert_command_stderr_eq!(left_command, right_expr)`\n",
    " left_command label: `command`,\n",
    " left_command debug: `\"printf\"`,\n",
    "   right_expr label: `s`,\n",
    "   right_expr debug: `\"hello\"`,\n",
    "               left: `\"usage: printf format [arguments ...]\\n\"`,\n",
    "              right: `\"hello\"`"
);
assert_eq!(actual, expect);