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

Assert a command stdout string is equal to another.

  • 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"]);
let mut b = Command::new("printf");
b.args(["%s%s%s%s%s", "h", "e", "l", "l", "o"]);
assert_command_stdout_eq_other!(a, b);
//-> ()

let result = panic::catch_unwind(|| {
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"]);
assert_command_stdout_eq_other!(a, b);
//-> panic!
});
let actual = result.unwrap_err().downcast::<String>().unwrap().to_string();
let expect = concat!(
    "assertion failed: `assert_command_stdout_eq_other!(left_command, right_command)`\n",
    "  left command name: `a`,\n",
    " right command name: `b`,\n",
    "       left command: `\"printf\"`,\n",
    "      right command: `\"printf\"`,\n",
    "               left: `\"hello\"`,\n",
    "              right: `\"world\"`"
);
assert_eq!(actual, expect);

This macro has a second form where a custom message can be provided.