Skip to content

Commit

Permalink
feat(data): Expose versioned tests
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Oct 2, 2023
1 parent 2c47534 commit 283d356
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
const TESTS_DIR: include_dir::Dir =
include_dir::include_dir!("$CARGO_MANIFEST_DIR/assets/toml-test/tests");

pub fn versions() -> std::collections::HashMap<&'static str, Vec<&'static std::path::Path>> {
TESTS_DIR
.files()
.filter_map(|f| {
let name = f.path().file_name()?;
let version = name.to_str()?.strip_prefix("files-toml-")?;
let paths = std::str::from_utf8(f.contents())
.ok()?
.lines()
.map(|s| std::path::Path::new(s))
.collect::<Vec<_>>();
Some((version, paths))
})
.collect()
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Valid<'a> {
pub name: &'a std::path::Path,
Expand Down

0 comments on commit 283d356

Please sign in to comment.