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
nameis the name of the binary in the child project’s manifestmanifestis the path to the manifest file for the test binary, relative to the directory that the containing project is in. It should probably end inCargo.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>
impl<'a> TestBinary<'a>
sourcepub fn relative_to_parent(name: &'a str, manifest: &'a Path) -> Self
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.
sourcepub fn with_profile(&mut self, profile: &'a str) -> &mut Self
pub fn with_profile(&mut self, profile: &'a str) -> &mut Self
Specifies a profile to build the test binary with.
sourcepub fn no_default_features(&mut self) -> &mut Self
pub fn no_default_features(&mut self) -> &mut Self
Specifies not to enable default features.
sourcepub fn with_feature(&mut self, feature: &'a str) -> &mut Self
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.
sourcepub fn build(&mut self) -> Result<OsString, TestBinaryError>
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.