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
impl TestEnv
pub fn new(current_dir: &str) -> Option<Self>
pub fn push(&self, child: &str) -> Option<Self>
pub fn current_dir(&self) -> &str
pub fn clear_log(&self) -> Option<()>
pub fn logln(&self, msg: &str) -> Option<()>
pub fn logln_to(&self, msg: &str, rel_path: impl AsRef<Path>) -> Option<()>
sourcepub fn read_file(&self, rel_path: impl AsRef<Path>) -> Option<String>
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
sourcepub fn write_file(
&self,
rel_path: impl AsRef<Path>,
contents: &str,
) -> Option<()>
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
sourcepub fn parse_file<T: DeserializeOwned>(
&self,
rel_path: impl AsRef<Path>,
) -> Option<T>
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
sourcepub fn copy_file_from(&self, path: impl AsRef<Path>) -> Option<()>
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
sourcepub fn copy_file_from_as(
&self,
path: impl AsRef<Path>,
new_name: &str,
) -> Option<()>
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
sourcepub fn copy_file_from_env(
&self,
other: &TestEnv,
path: impl AsRef<Path>,
) -> Option<()>
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
sourcepub fn copy_file_from_env_as(
&self,
other: &TestEnv,
path: impl AsRef<Path>,
new_name: &str,
) -> Option<()>
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
sourcepub fn remove_file(&self, rel_path: impl AsRef<Path>) -> Option<()>
pub fn remove_file(&self, rel_path: impl AsRef<Path>) -> Option<()>
Remove a file from a path relative to the environment current dir
sourcepub fn full_path(&self, rel_path: impl AsRef<Path>) -> PathBuf
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
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TestEnv
impl RefUnwindSafe for TestEnv
impl Send for TestEnv
impl Sync for TestEnv
impl Unpin for TestEnv
impl UnwindSafe for TestEnv
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)