macro_rules! assert_command_stderr_regex {
    ($command:expr, $regex:expr $(,)?) => { ... };
    ($command:expr, $regex:expr, $($arg:tt)+) => { ... };
}
Expand description

Assert a command stderr string is a match to a given regex.

  • When true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

Examples

use std::process::Command;
use regex::Regex;

let mut a = Command::new("printf");
let regex = Regex::new(r"usage").unwrap();
assert_command_stderr_regex!(a, regex);
//-> ()

let mut a = Command::new("printf");
let regex = Regex::new(r"xyz").unwrap();
assert_command_stderr_regex!(a, regex);
//-> panic!("…")
// assertion failed: `assert_command_stderr_regex!(command, regex)`
//  command program: `\"printf\"`,
//  regex: `xyz`,
//  stderr: `\"usage: printf format [arguments ...]\\n\"`,

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