# Struct run_make_support::command::Command

source ·

    pub struct Command {
        cmd: Command,
        stdin: Option<Box<[u8]>>,
        drop_bomb: DropBomb,
    }

Expand description

This is a custom command wrapper that simplifies working with commands and makes it easier to ensure that we check the exit status of executed processes.

## §A `Command` must be executed

A `Command` is armed by a [`DropBomb`] on construction to enforce that it will be executed. If a `Command` is constructed but never executed, the drop bomb will explode and cause the test to panic. Execution methods `run` and `run_fail` will defuse the drop bomb. A test containing constructed but never executed commands is dangerous because it can give a false sense of confidence.

## Fields§

§`cmd: Command`§`stdin: Option<Box<[u8]>>`§`drop_bomb: DropBomb`

## Implementations§

source§

### impl Command

source

#### pub fn new<P: AsRef<OsStr>>(program: P) -> Self

source

#### pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self

Specify a stdin input

source

#### pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Self
where K: AsRef<OsStr>, V: AsRef<OsStr>,

Specify an environment variable.

source

#### pub fn env_remove<K>(&mut self, key: K) -> &mut Self
where K: AsRef<OsStr>,

Remove an environmental variable.

source

#### pub fn arg<S>(&mut self, arg: S) -> &mut Self
where S: AsRef<OsStr>,

Generic command argument provider. Prefer specific helper methods if possible. Note that for some executables, arguments might be platform specific. For C/C++ compilers, arguments might be platform and compiler specific.

source

#### pub fn args<S, V>(&mut self, args: V) -> &mut Self
where S: AsRef<OsStr>, V: AsRef<[S]>,

Generic command arguments provider. Prefer specific helper methods if possible. Note that for some executables, arguments might be platform specific. For C/C++ compilers, arguments might be platform and compiler specific.

source

#### pub fn inspect<I>(&mut self, inspector: I) -> &mut Self
where I: FnOnce(&StdCommand),

Inspect what the underlying `std::process::Command` is up to the current construction.

source

#### pub fn current_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Set the path where the command will be run.

source

#### pub fn run(&mut self) -> CompletedProcess

Run the constructed command and assert that it is successfully run.

source

#### pub fn run_fail(&mut self) -> CompletedProcess

Run the constructed command and assert that it does not successfully run.

source

#### pub fn run_unchecked(&mut self) -> CompletedProcess

Run the command but do not check its exit status. Only use if you explicitly don’t care about the exit status. Prefer to use `Self::run` and `Self::run_fail` whenever possible.

source

#### fn command_output(&mut self) -> CompletedProcess

## Trait Implementations§

source§

### impl Debug for Command

source§

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

Formats the value using the given formatter. Read more

## Auto Trait Implementations§

§

### impl Freeze for Command

§

### impl !RefUnwindSafe for Command

§

### impl Send for Command

§

### impl Sync for Command

§

### impl Unpin for Command

§

### impl !UnwindSafe for Command

## 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>,

§

#### 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>,

§

#### 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.

## Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain `repr(...)` attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 280 bytes