pub struct ExampleChild { /* private fields */ }
Expand description
A wrapper around std::process::Child
that allows us to wait for a specific outputs.
Terminates the inner Child
process when dropped.
Implementations§
Source§impl ExampleChild
impl ExampleChild
pub fn run_new( pkg_name: &str, test_name: &str, args: impl IntoIterator<Item = impl AsRef<OsStr>>, ) -> Self
Sourcepub fn read_string(&mut self, wait_for_string: &str)
pub fn read_string(&mut self, wait_for_string: &str)
Waits for a specific string process output before returning.
When a child process is spawned often you want to wait until the child process is ready before moving on. One way to do that synchronization is by waiting for the child process to output something and match regex against that output. For example, you could wait until the child process outputs “Client live!” which would indicate that it is ready to receive input now on stdin.
Sourcepub fn read_regex(&mut self, wait_for_regex: &str)
pub fn read_regex(&mut self, wait_for_regex: &str)
Waits for a specific regex process output before returning.
Sourcepub fn write_line(&mut self, line: &str)
pub fn write_line(&mut self, line: &str)
Writes a line to the child process stdin. A newline is automatically appended and should not be included in line
.
Trait Implementations§
Source§impl Drop for ExampleChild
Terminates the inner Child
process when dropped.
impl Drop for ExampleChild
Terminates the inner Child
process when dropped.
When a Child
is dropped normally nothing happens but in unit tests you usually want to
terminate the child and wait for it to terminate. This does that for us.