Attribute Macro fstest

Source
#[fstest]
Expand description

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

This macro generates a #[test] function that:

  • Creates a temporary directory
  • Optionally initializes a Git repository (via repo = true)
  • Optionally copies specified files into the temp directory (via files = "path1", "path2", ...)
  • Invokes the annotated function (renamed with _inner suffix) with the temp directory path
  • Resets the working directory after the test

§Parameters

  • repo: bool — If true, initializes a Git repository in the temp directory before the test.
  • files: &[&str] relative file paths to copy.

§Example

use fstest::fstest;

#[fstest(repo = true, files = ["tests/data/config.toml", "tests/data/input.txt"])]
fn integration_example() {
    let config_path = std::fs::Path::new("config.toml");
    assert!(config_path.exists());
}