pub struct ShellOptions<Cmd = Command> { /* private fields */ }
Expand description

Options for executing commands in the shell. Used in Transcript::from_inputs() and in TestConfig.

The type param maps to extensions available for the shell. For example, StdShell extension allows to specify custom aliases for the executed commands.

Implementations

Creates options for an sh shell.

Creates options for a Bash shell.

Creates options for PowerShell.

Creates an alias for the binary at path_to_bin, which should be an absolute path. This allows to call the binary using this alias without complex preparations (such as installing it globally via cargo install), and is more flexible than Self::with_cargo_path().

In integration tests, you may use env!("CARGO_BIN_EXE_<name>") to get a path to binary targets.

Limitations
  • For Bash and PowerShell, name must be a valid name of a function. For sh, name must be a valid name for the alias command. The name validity is not checked.

Creates new options with the provided command.

Changes the current directory of the command.

Sets the I/O timeout for shell commands. This determines how long methods like Transcript::from_inputs() wait for output of a command before proceeding to the next command. Longer values allow to capture output more accurately, but result in longer execution.

By default, the I/O timeout is 1 second.

Sets an additional initialization timeout (relative to the one set by Self::with_io_timeout()) before reading the output of the first command.

By default, the initialization timeout is zero.

Adds an initialization command. Such commands are sent to the shell before executing any user input. The corresponding output from the shell is not captured.

Sets the value of an environment variable with the specified name.

Sets the line mapper for the shell. This allows to filter and/or map terminal outputs.

Adds paths to cargo binaries (including examples) to the PATH env variable for the shell described by these options. This allows to call them by the corresponding filename, without specifying a path or doing complex preparations (e.g., calling cargo install).

Limitations
  • The caller must be a unit or integration test; the method will work improperly otherwise.

Adds a specified path to the PATH env variable for the shell described by these options. This method can be called multiple times to add multiple paths and is composable with Self::with_cargo_path().

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.