diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-30 12:18:32 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-30 12:18:32 +0000 |
commit | 0c2e7032b1e5e067edd35e22f2f317f32ad9fc60 (patch) | |
tree | 299e54b269981c198ed761bb85a724738aa95ae4 /crates/test_utils | |
parent | 5dcd9fdf5e95573de9bc46f32b86d6fbc5e7c18d (diff) | |
parent | c445c72eb355dfd45d1ce1dd68087f7cf7c05877 (diff) |
Merge #2952
2952: Simplify fixture parsing r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/test_utils')
-rw-r--r-- | crates/test_utils/src/lib.rs | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 5666445aa..336c594a6 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs | |||
@@ -188,29 +188,16 @@ pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> { | |||
188 | } | 188 | } |
189 | }); | 189 | }); |
190 | 190 | ||
191 | let mut res = Vec::new(); | 191 | let mut res: Vec<FixtureEntry> = Vec::new(); |
192 | let mut meta = None; | 192 | for line in lines.by_ref() { |
193 | loop { | 193 | if line.starts_with("//-") { |
194 | let mut next_meta = None; | 194 | let meta = line["//-".len()..].trim().to_string(); |
195 | let mut text = String::new(); | 195 | res.push(FixtureEntry { meta, text: String::new() }) |
196 | for line in lines.by_ref() { | 196 | } else if let Some(entry) = res.last_mut() { |
197 | if line.starts_with("//-") { | 197 | entry.text.push_str(line); |
198 | next_meta = Some(line["//-".len()..].trim().to_string()); | 198 | entry.text.push('\n'); |
199 | break; | ||
200 | } | ||
201 | text.push_str(line); | ||
202 | text.push('\n'); | ||
203 | } | ||
204 | |||
205 | if let Some(meta) = meta { | ||
206 | res.push(FixtureEntry { meta, text }); | ||
207 | } | ||
208 | meta = next_meta; | ||
209 | if meta.is_none() { | ||
210 | break; | ||
211 | } | 199 | } |
212 | } | 200 | } |
213 | |||
214 | res | 201 | res |
215 | } | 202 | } |
216 | 203 | ||