Skip to main content

CommandOutput

Struct CommandOutput 

Source
pub struct CommandOutput {
    pub status: ExitStatus,
    pub stdout: Vec<u8>,
    pub stderr: Vec<u8>,
}
Expand description

Output captured from a CLI integration test.

command! runs the package’s compiled binary, so this includes the same stdout, stderr, and exit status a user receives. Keep these tests under tests/: Cargo defines the binary path for integration tests, not for a crate’s unit tests.

Fields§

§status: ExitStatus

The process exit status.

§stdout: Vec<u8>

Stdout exactly as the process wrote it.

§stderr: Vec<u8>

Stderr exactly as the process wrote it.

Implementations§

Source§

impl CommandOutput

Source

pub fn assert_success(self) -> Self

Assert that the command succeeded, printing stderr when it did not.

Source

pub fn stdout_text(&self) -> &str

Stdout as UTF-8.

Use the public Self::stdout bytes directly when non-UTF-8 output is intentional.

Source

pub fn stderr_text(&self) -> &str

Stderr as UTF-8.

Use the public Self::stderr bytes directly when non-UTF-8 output is intentional.

Trait Implementations§

Source§

impl Debug for CommandOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.