Macro assert_command_stdout_string_is_match

Source
macro_rules! assert_command_stdout_string_is_match {
    ($command:expr, $matcher:expr $(,)?) => { ... };
    ($command:expr, $matcher:expr, $($message:tt)+) => { ... };
}
Expand description

Assert a command stdout string is a match to a regex.

Pseudocode:
(command ⇒ stdout ⇒ string) is match (expr into string)

  • If true, return (command ⇒ stdout ⇒ 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-stdout");
command.args(["%s", "alfa"]);
let matcher = Regex::new(r"lf").expect("regex");
assert_command_stdout_string_is_match!(command, matcher);

// This will panic
let mut command = Command::new("bin/printf-stdout");
command.args(["%s", "alfa"]);
let matcher = Regex::new(r"zz").expect("regex");
assert_command_stdout_string_is_match!(command, matcher);
// assertion failed: `assert_command_stdout_string_is_match!(command, matcher)`
// https://docs.rs/assertables/…/assertables/macro.assert_command_stdout_string_is_match.html
//  command label: `command`,
//  command debug: `\"bin/printf-stdout\" \"%s\" \"alfa\"`,
//  command value: `\"alfa\"`,
//  matcher label: `matcher`,
//  matcher debug: `Regex(\"zz\")`,
//  matcher value: `Regex(\"zz\")`

§Module macros