macro_rules! assert_command_stdout_is_match { ($command:expr, $matcher:expr $(,)?) => { ... }; ($command:expr, $matcher:expr, $($message:tt)+) => { ... }; }
Expand description
Assert command stdout string is a match to a regex.
Pseudocode:
(command ⇒ stdout ⇒ string) is match (expr into string)
-
If 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 command = Command::new("bin/printf-stdout");
command.args(["%s", "hello"]);
let matcher = Regex::new(r"ell").unwrap();
assert_command_stdout_is_match!(command, &matcher);
let mut command = Command::new("bin/printf-stdout");
command.args(["%s", "hello"]);
let matcher = Regex::new(r"zzz").unwrap();
assert_command_stdout_is_match!(command, &matcher);
// assertion failed: `assert_command_stdout_is_match!(command, matcher)`
// https://docs.rs/assertables/8.7.0/assertables/macro.assert_command_stdout_is_match.html
// command label: `command`,
// command debug: `\"bin/printf-stdout\" \"%s\" \"hello\"`,
// matcher label: `&matcher`,
// matcher debug: `Regex(\"zzz\")`,
// command value: `\"hello\"`,
// matcher value: `Regex(\"zzz\")`