pub struct ScriptedRunner { /* private fields */ }Expand description
A CommandRunner that answers from a table and records what it was asked.
Match rules are checked in the order they were added, against the
space-joined command line, as a substring. The first rule that matches
answers; an unmatched request gets ScriptedRunner::default_response,
which starts as a successful, silent exit.
Implementations§
Source§impl ScriptedRunner
impl ScriptedRunner
Sourcepub fn always(self, contains: &str, response: CommandOutput) -> Self
pub fn always(self, contains: &str, response: CommandOutput) -> Self
Answers any request whose command line contains contains with
response, for every match.
Sourcepub fn sequence(self, contains: &str, responses: Vec<CommandOutput>) -> Self
pub fn sequence(self, contains: &str, responses: Vec<CommandOutput>) -> Self
Answers successive matches of contains with successive responses, and
repeats the last one once the list is exhausted.
Sourcepub fn otherwise(self, response: CommandOutput) -> Self
pub fn otherwise(self, response: CommandOutput) -> Self
Replaces the answer given to a request no rule matched.
Sourcepub fn recorded(&self) -> Vec<RecordedRequest>
pub fn recorded(&self) -> Vec<RecordedRequest>
Every request, in the order it was made.
Sourcepub fn call_count(&self) -> usize
pub fn call_count(&self) -> usize
How many requests were made.
Sourcepub fn command_lines(&self) -> Vec<String>
pub fn command_lines(&self) -> Vec<String>
The command lines, joined, for a coarse assertion.
Sourcepub fn piped_input(&self) -> Vec<u8> ⓘ
pub fn piped_input(&self) -> Vec<u8> ⓘ
Everything that was written to a child’s stdin, concatenated.
The documented door for a security test in another crate: it is the one place a piped payload can be read back, so an assertion that a canary is here and nowhere else has exactly one thing to look at.