Skip to content

Commit

Permalink
Merge pull request #53 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 authored Oct 2, 2023
2 parents 90dcbad + e69d6c9 commit cf7b2e9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion crates/harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pub struct EncoderHarness<E, D> {
encoder: E,
fixture: D,
matches: Option<Matches>,
version: Option<String>,
}

impl<E, D> EncoderHarness<E, D>
Expand All @@ -119,6 +120,7 @@ where
encoder,
fixture,
matches: None,
version: None,
}
}

Expand All @@ -130,8 +132,21 @@ 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 versioned = self
.version
.as_deref()
.into_iter()
.flat_map(toml_test_data::version)
.collect::<std::collections::HashSet<_>>();

let mut tests = Vec::new();
let encoder = self.encoder;
let fixture = self.fixture;
Expand All @@ -142,7 +157,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 cf7b2e9

Please sign in to comment.