|
46 | 46 | #[derive(Debug, Default)] |
47 | 47 | pub(crate) struct TestEntry { |
48 | 48 | pub entry: Entry<TestOutcome>, |
49 | | - pub subtests: IndexMap<String, Entry<SubtestOutcome>>, |
| 49 | + pub subtests: BTreeMap<String, Entry<SubtestOutcome>>, |
50 | 50 | } |
51 | 51 |
|
52 | 52 | #[derive(Debug)] |
@@ -186,6 +186,93 @@ pub(crate) fn process_reports( |
186 | 186 | let mut other_entries_by_test = IndexMap::<TestEntryPath<'_>, TestEntry>::default(); |
187 | 187 | let old_meta_file_paths = meta_files_by_path.keys().cloned().collect::<Vec<_>>(); |
188 | 188 |
|
| 189 | + log::debug!("loading metadata for comparison to reports…"); |
| 190 | + for (path, file) in meta_files_by_path { |
| 191 | + let File { properties, tests } = file; |
| 192 | + |
| 193 | + let file_rel_path = path.strip_prefix(checkout).unwrap(); |
| 194 | + |
| 195 | + file_props_by_file.insert( |
| 196 | + Utf8PathBuf::from(file_rel_path.to_str().unwrap()), |
| 197 | + properties, |
| 198 | + ); |
| 199 | + |
| 200 | + for (SectionHeader(name), test) in tests { |
| 201 | + let Test { |
| 202 | + properties, |
| 203 | + subtests, |
| 204 | + } = test; |
| 205 | + |
| 206 | + let test_entry_path = |
| 207 | + match TestEntryPath::from_metadata_test(browser, file_rel_path, &name) { |
| 208 | + Ok(ok) => ok, |
| 209 | + Err(e) => { |
| 210 | + log::error!("{e}"); |
| 211 | + return Err(AlreadyReportedToCommandline); |
| 212 | + } |
| 213 | + }; |
| 214 | + |
| 215 | + let freak_out_do_nothing = |
| 216 | + |what: &dyn Display| log::error!("hoo boy, not sure what to do yet: {what}"); |
| 217 | + |
| 218 | + let mut reported_dupe_already = false; |
| 219 | + let mut dupe_err = || { |
| 220 | + if !reported_dupe_already { |
| 221 | + freak_out_do_nothing(&format_args!( |
| 222 | + concat!( |
| 223 | + "duplicate entry for {:?}", |
| 224 | + "discarding previous entries with ", |
| 225 | + "this and further dupes" |
| 226 | + ), |
| 227 | + test_entry_path |
| 228 | + )) |
| 229 | + } |
| 230 | + reported_dupe_already = true; |
| 231 | + }; |
| 232 | + |
| 233 | + let TestEntry { |
| 234 | + entry: test_entry, |
| 235 | + subtests: subtest_entries, |
| 236 | + } = if let Some(cts_path) = cts_path(&test_entry_path) { |
| 237 | + let entry = entries_by_cts_path.entry(cts_path).or_default(); |
| 238 | + if let Some(_old) = entry |
| 239 | + .metadata_path |
| 240 | + .replace(test_entry_path.clone().into_owned()) |
| 241 | + { |
| 242 | + dupe_err(); |
| 243 | + } |
| 244 | + &mut entry.entry |
| 245 | + } else { |
| 246 | + other_entries_by_test |
| 247 | + .entry(test_entry_path.clone().into_owned()) |
| 248 | + .or_default() |
| 249 | + }; |
| 250 | + |
| 251 | + let test_entry_path = &test_entry_path; |
| 252 | + |
| 253 | + if let Some(_old) = test_entry.meta_props.replace(properties) { |
| 254 | + dupe_err(); |
| 255 | + } |
| 256 | + |
| 257 | + for (SectionHeader(subtest_name), subtest) in subtests { |
| 258 | + let Subtest { properties } = subtest; |
| 259 | + let subtest_entry = subtest_entries.entry(subtest_name.clone()).or_default(); |
| 260 | + if let Some(_old) = subtest_entry.meta_props.replace(properties) { |
| 261 | + if !reported_dupe_already { |
| 262 | + freak_out_do_nothing(&format_args!( |
| 263 | + concat!( |
| 264 | + "duplicate subtest in {:?} named {:?}, ", |
| 265 | + "discarding previous entries with ", |
| 266 | + "this and further dupes" |
| 267 | + ), |
| 268 | + test_entry_path, subtest_name |
| 269 | + )); |
| 270 | + } |
| 271 | + } |
| 272 | + } |
| 273 | + } |
| 274 | + } |
| 275 | + |
189 | 276 | log::debug!("gathering reported test outcomes for reconciliation with metadata…"); |
190 | 277 |
|
191 | 278 | let (exec_reports_sender, exec_reports_receiver) = channel(); |
@@ -322,93 +409,6 @@ pub(crate) fn process_reports( |
322 | 409 | } |
323 | 410 | } |
324 | 411 |
|
325 | | - log::debug!("loading metadata for comparison to reports…"); |
326 | | - for (path, file) in meta_files_by_path { |
327 | | - let File { properties, tests } = file; |
328 | | - |
329 | | - let file_rel_path = path.strip_prefix(checkout).unwrap(); |
330 | | - |
331 | | - file_props_by_file.insert( |
332 | | - Utf8PathBuf::from(file_rel_path.to_str().unwrap()), |
333 | | - properties, |
334 | | - ); |
335 | | - |
336 | | - for (SectionHeader(name), test) in tests { |
337 | | - let Test { |
338 | | - properties, |
339 | | - subtests, |
340 | | - } = test; |
341 | | - |
342 | | - let test_entry_path = |
343 | | - match TestEntryPath::from_metadata_test(browser, file_rel_path, &name) { |
344 | | - Ok(ok) => ok, |
345 | | - Err(e) => { |
346 | | - log::error!("{e}"); |
347 | | - return Err(AlreadyReportedToCommandline); |
348 | | - } |
349 | | - }; |
350 | | - |
351 | | - let freak_out_do_nothing = |
352 | | - |what: &dyn Display| log::error!("hoo boy, not sure what to do yet: {what}"); |
353 | | - |
354 | | - let mut reported_dupe_already = false; |
355 | | - let mut dupe_err = || { |
356 | | - if !reported_dupe_already { |
357 | | - freak_out_do_nothing(&format_args!( |
358 | | - concat!( |
359 | | - "duplicate entry for {:?}", |
360 | | - "discarding previous entries with ", |
361 | | - "this and further dupes" |
362 | | - ), |
363 | | - test_entry_path |
364 | | - )) |
365 | | - } |
366 | | - reported_dupe_already = true; |
367 | | - }; |
368 | | - |
369 | | - let TestEntry { |
370 | | - entry: test_entry, |
371 | | - subtests: subtest_entries, |
372 | | - } = if let Some(cts_path) = cts_path(&test_entry_path) { |
373 | | - let entry = entries_by_cts_path.entry(cts_path).or_default(); |
374 | | - if let Some(_old) = entry |
375 | | - .metadata_path |
376 | | - .replace(test_entry_path.clone().into_owned()) |
377 | | - { |
378 | | - dupe_err(); |
379 | | - } |
380 | | - &mut entry.entry |
381 | | - } else { |
382 | | - other_entries_by_test |
383 | | - .entry(test_entry_path.clone().into_owned()) |
384 | | - .or_default() |
385 | | - }; |
386 | | - |
387 | | - let test_entry_path = &test_entry_path; |
388 | | - |
389 | | - if let Some(_old) = test_entry.meta_props.replace(properties) { |
390 | | - dupe_err(); |
391 | | - } |
392 | | - |
393 | | - for (SectionHeader(subtest_name), subtest) in subtests { |
394 | | - let Subtest { properties } = subtest; |
395 | | - let subtest_entry = subtest_entries.entry(subtest_name.clone()).or_default(); |
396 | | - if let Some(_old) = subtest_entry.meta_props.replace(properties) { |
397 | | - if !reported_dupe_already { |
398 | | - freak_out_do_nothing(&format_args!( |
399 | | - concat!( |
400 | | - "duplicate subtest in {:?} named {:?}, ", |
401 | | - "discarding previous entries with ", |
402 | | - "this and further dupes" |
403 | | - ), |
404 | | - test_entry_path, subtest_name |
405 | | - )); |
406 | | - } |
407 | | - } |
408 | | - } |
409 | | - } |
410 | | - } |
411 | | - |
412 | 412 | log::debug!("metadata and reports gathered, now reconciling outcomes…"); |
413 | 413 |
|
414 | 414 | let entries_by_cts_path = entries_by_cts_path.into_iter().map(|(_name, entry)| { |
@@ -582,7 +582,7 @@ pub(crate) fn process_reports( |
582 | 582 | }, |
583 | 583 | )) |
584 | 584 | }) |
585 | | - .collect::<IndexMap<_, _>>(); |
| 585 | + .collect::<BTreeMap<_, _>>(); |
586 | 586 |
|
587 | 587 | Some((test_entry_path, (properties, subtests))) |
588 | 588 | }, |
|
0 commit comments