pub struct UniFFITestHelper { /* private fields */ }
Expand description
Struct for running fixture and example tests for bindings generators
Expectations:
- Used from a integration test (a
.rs
file in the tests/ directory) - The working directory is the project root for the bindings crate. This is the normal case for test code, just make sure you don’t cd somewhere else.
- The bindings crate has a dev-dependency on the fixture crate
- The fixture crate produces a cdylib library
- The fixture crate, and any external-crates, has 1 UDL file in it’s src/ directory
Implementations§
Source§impl UniFFITestHelper
impl UniFFITestHelper
pub fn new(name: &str) -> Result<Self>
Sourcepub fn create_out_dir(
&self,
temp_dir: impl AsRef<Utf8Path>,
script_path: impl AsRef<Utf8Path>,
) -> Result<Utf8PathBuf>
pub fn create_out_dir( &self, temp_dir: impl AsRef<Utf8Path>, script_path: impl AsRef<Utf8Path>, ) -> Result<Utf8PathBuf>
Create at out_dir
for testing
This directory can be used for:
- Generated bindings files (usually via the
--out-dir
param) - cdylib libraries that the bindings depend on
- Anything else that’s useful for testing
This directory typically created as a subdirectory of CARGO_TARGET_TMPDIR
when running an
integration test.
We use the script path to create a hash included in the outpuit directory. This avoids path collutions when 2 scripts run against the same fixture.
Sourcepub fn copy_cdylib_to_out_dir(
&self,
out_dir: impl AsRef<Utf8Path>,
) -> Result<Utf8PathBuf>
pub fn copy_cdylib_to_out_dir( &self, out_dir: impl AsRef<Utf8Path>, ) -> Result<Utf8PathBuf>
Copy the cdylib
for a fixture into the out_dir
This is typically needed for the bindings to open it when running the tests
Returns the path to the copied library
Sourcepub fn cdylib_path(&self) -> Result<Utf8PathBuf>
pub fn cdylib_path(&self) -> Result<Utf8PathBuf>
Get the path to the cdylib file for this package
Auto Trait Implementations§
impl Freeze for UniFFITestHelper
impl RefUnwindSafe for UniFFITestHelper
impl Send for UniFFITestHelper
impl Sync for UniFFITestHelper
impl Unpin for UniFFITestHelper
impl UnwindSafe for UniFFITestHelper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more