diff options
author | Edwin Cheng <[email protected]> | 2020-03-09 18:02:43 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-03-10 16:45:03 +0000 |
commit | 773f3afd3628ed646fee561cb2a09a28454e72c8 (patch) | |
tree | c29e762c8df43683f9a541ddec92d4813ee59536 /crates/test_utils | |
parent | d53627beba8fddb02496dc69979c557bdb9c34cf (diff) |
Add fixture meta for single file fixture
Diffstat (limited to 'crates/test_utils')
-rw-r--r-- | crates/test_utils/src/lib.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 69deddcb5..2432177b4 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs | |||
@@ -202,6 +202,14 @@ 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 | ||
206 | pub fn parse_single_fixture(fixture: &str) -> Option<FixtureEntry> { | ||
207 | if !fixture.lines().any(|it| it.trim_start().starts_with("//-")) { | ||
208 | return None; | ||
209 | } | ||
210 | parse_fixture(fixture).into_iter().nth(0) | ||
211 | } | ||
212 | |||
205 | // Comparison functionality borrowed from cargo: | 213 | // Comparison functionality borrowed from cargo: |
206 | 214 | ||
207 | /// Compare a line with an expected pattern. | 215 | /// Compare a line with an expected pattern. |