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

Assert a command stderr string contains a given string.

  • When true, return Ok(()).

  • Otherwise, return Err with a message and the values of the expressions with their debug representations.

Examples

use std::process::Command;

let mut a = Command::new("printf");
let x = assertable_command_stderr_contains_str!(a, "usage");
//-> Ok(())
assert_eq!(x.unwrap(), ());

let mut a = Command::new("printf");
let x = assertable_command_stderr_contains_str!(a, "xyz");
//-> Err!("…")
// assertable failed: `assertable_command_stderr_contains_str!(command, str)`
//  command program: `\"printf\"`,
//  str: `\"xyz\"`
//  stderr: `\"usage: printf format [arguments ...]\\n\"`,

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