macro_rules! assert_command_stdout_contains { ($command:expr, $b:expr $(,)?) => { ... }; ($command:expr, $b:expr, $($message:tt)+) => { ... }; }
Expand description
Assert a command stdout string contains a given containee.
Pseudocode:
(command ⇒ stdout ⇒ string) contains (expr into string)
-
If true, return
(). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
This uses std::String method contains.
- The containee can be a &str, char, a slice of chars, or a function or closure that determines if a character contains.
§Examples
use std::process::Command;
let mut command = Command::new("bin/printf-stdout");
command.args(["%s", "hello"]);
let containee = "ell";
assert_command_stdout_contains!(command, &containee);
let mut command = Command::new("bin/printf-stdout");
command.args(["%s", "hello"]);
let containee = "zzz";
assert_command_stdout_contains!(command, &containee);
// assertion failed: `assert_command_stdout_contains!(command, containee)`
// https://docs.rs/assertables/8.9.0/assertables/macro.assert_command_stdout_contains.html
// command label: `command`,
// command debug: `\"bin/printf-stdout\" \"%s\" \"hello\"`,
// containee label: `&containee`,
// containee debug: `\"zzz\"`,
// command value: `\"hello\"`