Struct test_binary::TestBinary

source ·
pub struct TestBinary<'a> { /* private fields */ }
Expand description

Builder constructor for a test binary.

Start with TestBinary::relative_to_parent(name, manifest) where

  • name is the name of the binary in the child project’s manifest
  • manifest is the path to the manifest file for the test binary, relative to the directory that the containing project is in. It should probably end in Cargo.toml.

Note that you can pass a path in a cross-platform way by using PathBuf::from_iter():

TestBinary::relative_to_parent(
    "does-build",
    &PathBuf::from_iter(["testbins", "does-build", "Cargo.toml"]),
);

Implementations§

source§

impl<'a> TestBinary<'a>

source

pub fn relative_to_parent(name: &'a str, manifest: &'a Path) -> Self

Creates a new TestBinary by specifying the child binary’s manifest relative to the parent.

source

pub fn with_profile(&mut self, profile: &'a str) -> &mut Self

Specifies a profile to build the test binary with.

source

pub fn no_default_features(&mut self) -> &mut Self

Specifies not to enable default features.

source

pub fn with_feature(&mut self, feature: &'a str) -> &mut Self

Specifies a feature to enable for the test binary. These are additive, so if you call this multiple times all the features you specify will be enabled.

source

pub fn build(&mut self) -> Result<OsString, TestBinaryError>

Builds the binary crate we’ve prepared. This goes through Cargo, so it should function identically to cargo build --bin testbin along with any additional flags from the builder methods.

Trait Implementations§

source§

impl<'a> Debug for TestBinary<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for TestBinary<'a>

§

impl<'a> Send for TestBinary<'a>

§

impl<'a> Sync for TestBinary<'a>

§

impl<'a> Unpin for TestBinary<'a>

§

impl<'a> UnwindSafe for TestBinary<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.