#proc-macro #macro #temp #test

yanked with_tempdir_procmacro

Inject a temporary directory and provide as an argument to the function

0.1.1 Aug 8, 2019
0.1.0 Aug 8, 2019

#26 in #temp

GPL-3.0-or-later

18KB
137 lines

Gitlab pipeline status Codecov

Tempdir injection for tests

This small project is providing you a procedural macro to inject a temporary directory in your test.

#[with_tempdir]
#[test]
fn my_test(path: &Path) {
  // do stuff in folder `path`
}

Look at the documentation for more.


lib.rs:

This crate provide the with_tempdir macro.

use with_tempdir_procmacro::with_tempdir;

#[with_tempdir(path = "/tmp/foo")]
#[test]
fn my_test(path: &Path) {
  let file_path = path.join("some_file.txt");
  let mut file = File::create(&file_path).expect("Failed to create the file");
}

Read the documentation of with_tempdir macro to know more.

Dependencies

~3–13MB
~157K SLoC