macro_rules! assert_vfs_setup {
    ($vfs:expr $(, $func:expr )?) => { ... };
}
Expand description

Setup Vfs testing components

This provides an abstraction over VirtualFileSystem implementations such that we can easily switch out a Memfs backend for a Stdfs backend without modifying the testing algorithms. Vfs tests will default to using the testing::TEST_TEMP_DIR as the root of testing and create a new directory inside that using the derived fully qualified function name or given function name when it can’t be derived.

Warning

Since doc tests always have a default function name of rust_out::main its required to override the func_name param to get a unique directory to work with in the Stdfs case as you won’t get a unique directory created to work from and could cause testing collisions.

Returns

  • vfs - the vfs instance passed to the function for reference
  • tmpdir - the temp directory that was created for the test function to work in

Examples

use rivia::prelude::*;

let (vfs, tmpdir) = assert_vfs_setup!(Vfs::memfs(), "unique_func_name");
assert_vfs_remove_all!(vfs, &tmpdir);