[][src]Macro test_generator::glob_expand

glob_expand!() { /* proc-macro */ }

Function-Attribute macro expanding glob-file-pattern to a list of directories and generating a test-function for each one.

extern crate test_generator;
#[cfg(test)]
mod tests {
  use std::path::Path;
  use test_generator::glob_expand;

  glob_expand! { "data/*"; generic_test }

  fn generic_test(dir_name: &str) { assert!(Path::new(dir_name).exists()); }
}

The macro will expand the code for each subfolder in "data/*", generating the following code. This code is not visible in IDE. Every build-time, the code will be newly generated.

mod tests {
    ///
    ///
    #[test]
    fn gen_data_testset1() {
        generic_test("data/testset1");
    }

    ///
    ///
    #[test]
    fn gen_data_testset2() {
        generic_test("data/testset2");
    }
}