aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-01-30 12:17:56 +0000
committerAleksey Kladov <[email protected]>2020-01-30 12:17:56 +0000
commitc445c72eb355dfd45d1ce1dd68087f7cf7c05877 (patch)
tree299e54b269981c198ed761bb85a724738aa95ae4 /crates/test_utils
parent5dcd9fdf5e95573de9bc46f32b86d6fbc5e7c18d (diff)
Simplify fixture parsing
Diffstat (limited to 'crates/test_utils')
-rw-r--r--crates/test_utils/src/lib.rs29
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