(body: &str)
| 254 | } |
| 255 | |
| 256 | fn parse_multi_file_body(body: &str) -> Result<(Vec<FixtureFile>, usize, u32, u32), String> { |
| 257 | let mut files = Vec::new(); |
| 258 | let mut cursor_file = None; |
| 259 | let mut cursor_line = 0u32; |
| 260 | let mut cursor_char = 0u32; |
| 261 | |
| 262 | let mut current_path: Option<String> = None; |
| 263 | let mut current_content = String::new(); |
| 264 | |
| 265 | for line in body.lines() { |
| 266 | if let Some(rest) = line.strip_prefix("=== ") |
| 267 | && let Some(path_str) = rest.strip_suffix(" ===") |
| 268 | { |
| 269 | // Flush previous file if any. |
| 270 | if let Some(path) = current_path.take() { |
| 271 | let content = std::mem::take(&mut current_content); |
| 272 | if content.contains("<>") { |
| 273 | let (stripped, cl, cc) = strip_cursor(&content)?; |
| 274 | cursor_file = Some(files.len()); |
| 275 | cursor_line = cl; |
| 276 | cursor_char = cc; |
| 277 | files.push(FixtureFile { |
| 278 | path, |
| 279 | content: stripped, |
| 280 | }); |
| 281 | } else { |
| 282 | files.push(FixtureFile { path, content }); |
| 283 | } |
| 284 | } |
| 285 | current_path = Some(path_str.trim().to_string()); |
| 286 | continue; |
| 287 | } |
| 288 | if current_path.is_some() { |
| 289 | if !current_content.is_empty() { |
| 290 | current_content.push('\n'); |
| 291 | } |
| 292 | current_content.push_str(line); |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | // Flush last file. |
| 297 | if let Some(path) = current_path { |
| 298 | let content = std::mem::take(&mut current_content); |
| 299 | if content.contains("<>") { |
| 300 | let (stripped, cl, cc) = strip_cursor(&content)?; |
| 301 | cursor_file = Some(files.len()); |
| 302 | cursor_line = cl; |
| 303 | cursor_char = cc; |
| 304 | files.push(FixtureFile { |
| 305 | path, |
| 306 | content: stripped, |
| 307 | }); |
| 308 | } else { |
| 309 | files.push(FixtureFile { path, content }); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | if files.is_empty() { |
no test coverage detected