fstest

Crates.iofstest
lib.rsfstest
version0.2.4
created_at2025-04-30 08:55:37.247233+00
updated_at2025-04-30 11:46:25.418023+00
descriptionA procedural macro for testing in tempdirs or git repos
homepage
repositoryhttps://github.com/jenskrumsieck/fstest
max_upload_size
id1654656
size42,185
Jens Krumsieck (JensKrumsieck)

documentation

README

fstest

Crates.io Version Crates.io Total Downloads 🦀 Continuous Integration Docs.rs License

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::cmd_test;
#[cmd_test(repo = true, files = ["tests/data/input.txt", "tests/data/config.toml"])] //arguments are optional!
fn my_test() {
    // test code working within `tempdir`
}

See examples folder for examples.

Installation

Add crate and serial_test and tempfile to your dev dependencies.

[dev-dependencies]
fstest = "*"
Commit count: 30

cargo fmt