pub struct TestChangeGuard { /* private fields */ }Expand description
RAII guard for test changes that auto-reverts on drop.
This ensures that test changes are always cleaned up, even if the test panics or returns early.
§Example
use std::path::Path;
use rch_common::test_change::{TestCodeChange, TestChangeGuard};
fn run_test() -> anyhow::Result<()> {
let change = TestCodeChange::for_main_rs(Path::new("/my/project"))?;
let guard = TestChangeGuard::new(change)?;
// Do compilation and testing here...
// File will be automatically reverted when guard goes out of scope
Ok(())
}Implementations§
Source§impl TestChangeGuard
impl TestChangeGuard
Sourcepub fn new(change: TestCodeChange) -> Result<Self>
pub fn new(change: TestCodeChange) -> Result<Self>
Create a new guard and apply the test change.
The change is applied immediately upon creation.
Sourcepub fn verify_in_binary(&self, binary_path: &Path) -> Result<bool>
pub fn verify_in_binary(&self, binary_path: &Path) -> Result<bool>
Check if the compiled binary contains the test marker.
Trait Implementations§
Source§impl Drop for TestChangeGuard
impl Drop for TestChangeGuard
Auto Trait Implementations§
impl Freeze for TestChangeGuard
impl RefUnwindSafe for TestChangeGuard
impl Send for TestChangeGuard
impl Sync for TestChangeGuard
impl Unpin for TestChangeGuard
impl UnsafeUnpin for TestChangeGuard
impl UnwindSafe for TestChangeGuard
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