Skip to content

Commit

Permalink
Merge pull request #52 from toml-rs/version
Browse files Browse the repository at this point in the history
feat(harness): Allow using versioned subsets
  • Loading branch information
epage committed Oct 2, 2023
2 parents 18c37c9 + 42c0b79 commit 99837be
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions crates/harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub use toml_test::Error;
pub struct DecoderHarness<D> {
decoder: D,
matches: Option<Matches>,
version: Option<String>,
}

impl<D> DecoderHarness<D>
Expand All @@ -21,6 +22,7 @@ where
Self {
decoder,
matches: None,
version: None,
}
}

Expand All @@ -32,10 +34,22 @@ where
Ok(self)
}

pub fn version(&mut self, version: impl Into<String>) -> &mut Self {
self.version = Some(version.into());
self
}

pub fn test(self) -> ! {
let args = libtest_mimic::Arguments::from_args();
let nocapture = args.nocapture;

let versioned = self
.version
.as_deref()
.into_iter()
.flat_map(toml_test_data::version)
.collect::<std::collections::HashSet<_>>();

let mut tests = Vec::new();
let decoder = self.decoder;
tests.extend(
Expand All @@ -45,7 +59,8 @@ where
.matches
.as_ref()
.map(|m| !m.matched(case.name))
.unwrap_or_default();
.unwrap_or_default()
|| !versioned.contains(case.name);
(case, ignore)
})
.map(move |(case, ignore)| {
Expand All @@ -64,7 +79,8 @@ where
.matches
.as_ref()
.map(|m| !m.matched(case.name))
.unwrap_or_default();
.unwrap_or_default()
|| !versioned.contains(case.name);
(case, ignore)
})
.map(move |(case, ignore)| {
Expand Down

0 comments on commit 99837be

Please sign in to comment.