aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils
diff options
context:
space:
mode:
Diffstat (limited to 'crates/test_utils')
-rw-r--r--crates/test_utils/src/lib.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index 69deddcb5..a0d8f4d37 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -202,6 +202,19 @@ pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> {
202 res 202 res
203} 203}
204 204
205/// Same as `parse_fixture`, except it allow empty fixture
206pub fn parse_single_fixture(fixture: &str) -> Option<FixtureEntry> {
207 if !fixture.lines().any(|it| it.trim_start().starts_with("//-")) {
208 return None;
209 }
210
211 let fixtures = parse_fixture(fixture);
212 if fixtures.len() > 1 {
213 panic!("too many fixtures");
214 }
215 fixtures.into_iter().nth(0)
216}
217
205// Comparison functionality borrowed from cargo: 218// Comparison functionality borrowed from cargo:
206 219
207/// Compare a line with an expected pattern. 220/// Compare a line with an expected pattern.