Skip to content

Allow to customize test function name #5

@Mingun

Description

@Mingun

For example, I want to test all formats from kaitai-struct gallery. I use following code (folder formats is git checkout of https://github.com/kaitai-io/kaitai_struct_formats repository):

#[cfg(test)]
mod formats {
  use std::fs::File;
  use test_generator::test_resources;
  use super::Ksy;

  #[test_resources("formats/**/*.ksy")]
  fn parse(resource: &str) {
    let file = File::open(resource).expect(&format!("can't read file {}", resource));
    let _: Ksy = serde_yaml::from_reader(file).expect(&format!("invalid file {}", resource));
  }
}

and get following output:

test parser::formats::parse_formats_archive_cpio_old_le_ksy ... ok
...

Generated function name seems repeat module name. I would be like see something like

test parser::formats::parse_archive_cpio_old_le_ksy ... ok
...

That can be implemented, for example, by introducing capture group in glob pattern, something like #[test_resources("formats/(**/*).ksy")]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions