TestEnv

Struct TestEnv 

Source
pub struct TestEnv { /* private fields */ }
Expand description

A test environment, which is essentially a wrapper around some directory, with some utility functions operating relative to that directory.

Implementations§

Source§

impl TestEnv

Source

pub fn new(current_dir: &str) -> Option<Self>

Source

pub fn push(&self, child: &str) -> Option<Self>

Source

pub fn current_dir(&self) -> &str

Source

pub fn clear_log(&self) -> Option<()>

Source

pub fn logln(&self, msg: &str) -> Option<()>

Source

pub fn logln_to(&self, msg: &str, rel_path: impl AsRef<Path>) -> Option<()>

Source

pub fn read_file(&self, rel_path: impl AsRef<Path>) -> Option<String>

Read a file from a path relative to the environment current dir into a string

Source

pub fn write_file( &self, rel_path: impl AsRef<Path>, contents: &str, ) -> Option<()>

Write a file to a path relative to the environment current dir

Source

pub fn parse_file<T: DeserializeOwned>( &self, rel_path: impl AsRef<Path>, ) -> Option<T>

Parse a file from a path relative to the environment current dir as the given type

Source

pub fn copy_file_from(&self, path: impl AsRef<Path>) -> Option<()>

Copy a file from the path outside environment into the environment current dir Returns None if copying was not successful

Source

pub fn copy_file_from_as( &self, path: impl AsRef<Path>, new_name: &str, ) -> Option<()>

Copy a file from the path outside environment into the environment current dir Assigns the file a new_name in the current environment Returns None if copying was not successful

Source

pub fn copy_file_from_env( &self, other: &TestEnv, path: impl AsRef<Path>, ) -> Option<()>

Copy a file from the path relative to the other environment into the environment current dir Returns None if copying was not successful

Source

pub fn copy_file_from_env_as( &self, other: &TestEnv, path: impl AsRef<Path>, new_name: &str, ) -> Option<()>

Copy a file from the path relative to the other environment into the environment current dir Assigns the file a new_name in the current environment Returns None if copying was not successful

Source

pub fn remove_file(&self, rel_path: impl AsRef<Path>) -> Option<()>

Remove a file from a path relative to the environment current dir

Source

pub fn full_path(&self, rel_path: impl AsRef<Path>) -> PathBuf

Convert a relative path to the full path from the test root Return None if the full path can’t be formed

Source

pub fn rel_path(&self, full_path: impl AsRef<Path>) -> Option<String>

Convert a full path to the path relative to the test root Returns None if the full path doesn’t contain test root as prefix

Source

pub fn full_canonical_path(&self, rel_path: impl AsRef<Path>) -> Option<String>

Convert a relative path to the full path from the test root, canonicalized Returns None the full path can’t be formed

Trait Implementations§

Source§

impl Clone for TestEnv

Source§

fn clone(&self) -> TestEnv

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TestEnv

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.