pub struct Runcmd { /* private fields */ }
Expand description

The Runcmd context gives a step function access to the ability to run subprocesses as part of a scenario. These subprocesses are run with various environment variables set, and we record the stdout/stderr of the most recent-to-run command for testing purposes.

Implementations

Prepend the given location to the run path

Retrieve the last run command’s stdout as a string.

This does a lossy conversion from utf8 so should always succeed.

Retrieve the last run command’s stderr as a string.

This does a lossy conversion from utf8 so should always succeed.

Set an env var in the Runcmd context

This sets an environment variable into the Runcmd context for use during execution

Get an env var from the Runcmd context

This retrieves a set environment variable from the Runcmd context

Unset an env var in the Runcmd context

This removes an environment variable (if set) from the Runcmd context and returns whether or not it was removed.

Join the PATH environment variable and the paths attribute together properly.

This prepends the paths (in reverse order) to the PATH environment variable and then returns it.

If there is no PATH in the stored environment then the resultant path will be entirely made up of the pushed path elements


let mut rc = Runcmd::default();

assert_eq!(rc.join_paths().unwrap(), "");

rc.setenv("PATH", "one");
assert_eq!(rc.join_paths().unwrap(), "one");

rc.prepend_to_path("two");
assert_eq!(rc.join_paths().unwrap(), "two:one");

rc.unsetenv("PATH");
assert_eq!(rc.join_paths().unwrap(), "two");

rc.prepend_to_path("three");
assert_eq!(rc.join_paths().unwrap(), "three:two");

rc.setenv("PATH", "one");
assert_eq!(rc.join_paths().unwrap(), "three:two:one");

Trait Implementations

Scenario starts Read more
A new context element was created. Read more
Scenario stops Read more
Entry to a step function Read more
Exit from a step function Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

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.