Crate fstest

Source
Expand description

§fstest

fstest provides a procedural macro attribute for simplifying integration tests involving temporary file system setups and optional Git repository initialization. This crate defines the #[fstest] macro, which wraps a test function and handles:

  • Creation of a temporary working directory
  • Optional initialization of a Git repository in the temporary directory
  • Copying of specified input files into the temp directory
  • Restoring the original working directory after test execution

§Usage

use fstest::fstest;

#[fstest(repo = true, files = ["tests/data/input.txt", "tests/data/config.toml"])] //arguments are optional!
fn my_test(tempdir: &std::path::Path) {
    // test code working within `tempdir`
}

Re-exports§

pub use serial_test;
pub use tempfile;

Functions§

create_repo_and_commit
Creates a new git repository in the given directory and makes an initial commit with all files in the repository. If there is no user configured, it sets a default user name and email. This function is used for setting up a new git repository for testing purposes.

Attribute Macros§

fstest
Attribute macro to create file-system-isolated integration tests with optional git repo setup.