macro_rules! assert_command_stderr_string_is_match {
($command:expr, $matcher:expr $(,)?) => { ... };
($command:expr, $matcher:expr, $($message:tt)+) => { ... };
}Expand description
Assert a command stderr string is a match to a regex.
Pseudocode:
(command ⇒ stderr ⇒ string) is match (expr into string)
-
If true, return (command ⇒ stderr ⇒ string).
-
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
§Examples
use assertables::*;
use std::process::Command;
use regex::Regex;
let mut command = Command::new("bin/printf-stderr");
command.args(["%s", "alfa"]);
let matcher = Regex::new(r"lf").expect("regex");
assert_command_stderr_string_is_match!(command, matcher);
// This will panic
let mut command = Command::new("bin/printf-stderr");
command.args(["%s", "alfa"]);
let matcher = Regex::new(r"zz").expect("regex");
assert_command_stderr_string_is_match!(command, matcher);
// assertion failed: `assert_command_stderr_string_is_match!(command, matcher)`
// https://docs.rs/assertables/…/assertables/macro.assert_command_stderr_string_is_match.html
// command label: `command`,
// command debug: `\"bin/printf-stderr\" \"%s\" \"alfa\"`,
// command value: `\"alfa\"`,
// matcher label: `matcher`,
// matcher debug: `Regex(\"zz\")`,
// matcher value: `Regex(\"zz\")`