macro_rules! assertable_command_stdout_contains_str {
($command:expr, $substr:expr $(,)?) => { ... };
($command:expr, $substr:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a command stdout string is equal to a target string.
-
When true, return
Ok(()). -
Otherwise, return
Errwith a message and the values of the expressions with their debug representations.
Examples
use std::process::Command;
let mut a = Command::new("printf");
a.args(["%s", "hello"]);
let x = assertable_command_stdout_contains_str!(a, "he");
//-> Ok(())
assert_eq!(x.unwrap(), ());
let mut a = Command::new("printf");
a.args(["%s", "hello"]);
let x = assertable_command_stdout_contains_str!(a, "xy");
//-> Err!("…")
// assertable failed: `assertable_command_stdout_contains_str!(command, substr)`
// command program: `\"printf\"`,
// stdout: `\"hello\"`,
// substr: `\"xy\"`This macro has a second form where a custom message can be provided.