ExampleChild

Struct ExampleChild 

Source
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

Source

pub fn run_new( pkg_name: &str, test_name: &str, args: impl IntoIterator<Item = impl AsRef<OsStr>>, ) -> Self

Source

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.

Source

pub fn read_regex(&mut self, wait_for_regex: &str)

Waits for a specific regex process output before returning.

Source

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.

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.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.