Skip to content

Commit 95531ed

Browse files
refactor: subvert/TestPath/TestEntryPath
1 parent 90dfee0 commit 95531ed

2 files changed

Lines changed: 72 additions & 67 deletions

File tree

moz-webgpu-cts/src/main.rs

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use self::{
1414
BuildProfile, File, FileProps, ImplementationStatus, Platform, Subtest, SubtestOutcome,
1515
Test, TestOutcome, TestProps,
1616
},
17-
path::TestPath,
17+
path::TestEntryPath,
1818
},
1919
};
2020

@@ -279,23 +279,23 @@ fn run(cli: Cli) -> ExitCode {
279279

280280
#[derive(Debug, Default)]
281281
struct EntryByCtsPath<'a> {
282-
metadata_path: Option<TestPath<'a>>,
283-
reported_path: Option<TestPath<'a>>,
282+
metadata_path: Option<TestEntryPath<'a>>,
283+
reported_path: Option<TestEntryPath<'a>>,
284284
entry: TestEntry,
285285
}
286286

287-
fn cts_path(test_path: &TestPath<'_>) -> Option<String> {
288-
test_path
287+
fn cts_path(test_entry_path: &TestEntryPath<'_>) -> Option<String> {
288+
test_entry_path
289289
.variant
290290
.as_ref()
291291
.filter(|v| v.starts_with("?q=webgpu:"))
292292
.map(|v| v.strip_prefix("?q=").unwrap().to_owned())
293-
.filter(|_q| test_path.path.ends_with("cts.https.html"))
293+
.filter(|_q| test_entry_path.path.ends_with("cts.https.html"))
294294
}
295295

296296
let mut file_props_by_file = IndexMap::<Utf8PathBuf, FileProps>::default();
297297
let mut entries_by_cts_path = IndexMap::<String, EntryByCtsPath<'_>>::default();
298-
let mut other_entries_by_test = IndexMap::<TestPath<'_>, TestEntry>::default();
298+
let mut other_entries_by_test = IndexMap::<TestEntryPath<'_>, TestEntry>::default();
299299
let old_meta_file_paths = meta_files_by_path.keys().cloned().collect::<Vec<_>>();
300300

301301
log::debug!("loading metadata for comparison to reports…");
@@ -315,8 +315,8 @@ fn run(cli: Cli) -> ExitCode {
315315
subtests,
316316
} = test;
317317

318-
let test_path =
319-
TestPath::from_metadata_test(browser, file_rel_path, &name).unwrap();
318+
let test_entry_path =
319+
TestEntryPath::from_metadata_test(browser, file_rel_path, &name).unwrap();
320320

321321
let freak_out_do_nothing = |what: &dyn Display| {
322322
log::error!("hoo boy, not sure what to do yet: {what}")
@@ -331,7 +331,7 @@ fn run(cli: Cli) -> ExitCode {
331331
"discarding previous entries with ",
332332
"this and further dupes"
333333
),
334-
test_path
334+
test_entry_path
335335
))
336336
}
337337
reported_dupe_already = true;
@@ -340,21 +340,22 @@ fn run(cli: Cli) -> ExitCode {
340340
let TestEntry {
341341
entry: test_entry,
342342
subtests: subtest_entries,
343-
} = if let Some(cts_path) = cts_path(&test_path) {
343+
} = if let Some(cts_path) = cts_path(&test_entry_path) {
344344
let entry = entries_by_cts_path.entry(cts_path).or_default();
345-
if let Some(_old) =
346-
entry.metadata_path.replace(test_path.clone().into_owned())
345+
if let Some(_old) = entry
346+
.metadata_path
347+
.replace(test_entry_path.clone().into_owned())
347348
{
348349
dupe_err();
349350
}
350351
&mut entry.entry
351352
} else {
352353
other_entries_by_test
353-
.entry(test_path.clone().into_owned())
354+
.entry(test_entry_path.clone().into_owned())
354355
.or_default()
355356
};
356357

357-
let test_path = &test_path;
358+
let test_entry_path = &test_entry_path;
358359

359360
if let Some(_old) = test_entry.meta_props.replace(properties) {
360361
dupe_err();
@@ -372,7 +373,7 @@ fn run(cli: Cli) -> ExitCode {
372373
"discarding previous entries with ",
373374
"this and further dupes"
374375
),
375-
test_path, subtest_name
376+
test_entry_path, subtest_name
376377
));
377378
}
378379
}
@@ -445,16 +446,18 @@ fn run(cli: Cli) -> ExitCode {
445446
for entry in entries {
446447
let TestExecutionEntry { test_name, result } = entry;
447448

448-
let test_path = TestPath::from_execution_report(browser, &test_name).unwrap();
449+
let test_entry_path =
450+
TestEntryPath::from_execution_report(browser, &test_name).unwrap();
449451
let TestEntry {
450452
entry: test_entry,
451453
subtests: subtest_entries,
452-
} = if let Some(cts_path) = cts_path(&test_path) {
454+
} = if let Some(cts_path) = cts_path(&test_entry_path) {
453455
let entry = entries_by_cts_path.entry(cts_path).or_default();
454-
if let Some(old) =
455-
entry.reported_path.replace(test_path.clone().into_owned())
456+
if let Some(old) = entry
457+
.reported_path
458+
.replace(test_entry_path.clone().into_owned())
456459
{
457-
if old != test_path {
460+
if old != test_entry_path {
458461
log::warn!(
459462
concat!(
460463
"found test execution entry containing the same ",
@@ -465,14 +468,14 @@ fn run(cli: Cli) -> ExitCode {
465468
"newer: {:#?}\n",
466469
),
467470
old,
468-
test_path
471+
test_entry_path
469472
)
470473
}
471474
}
472475
&mut entry.entry
473476
} else {
474477
other_entries_by_test
475-
.entry(test_path.clone().into_owned())
478+
.entry(test_entry_path.clone().into_owned())
476479
.or_default()
477480
};
478481

@@ -485,7 +488,7 @@ fn run(cli: Cli) -> ExitCode {
485488
"expected an empty `status` field for {:?}, ",
486489
"but found the {:?} status"
487490
),
488-
test_path,
491+
test_entry_path,
489492
status,
490493
)
491494
}
@@ -575,7 +578,7 @@ fn run(cli: Cli) -> ExitCode {
575578
});
576579
let recombined_tests_iter = entries_by_cts_path
577580
.chain(other_entries_by_test)
578-
.filter_map(|(test_path, test_entry)| {
581+
.filter_map(|(test_entry_path, test_entry)| {
579582
/// Reconciles `meta_props` with `reported` if they match
580583
/// `implementation_status_filter`.
581584
///
@@ -648,12 +651,13 @@ fn run(cli: Cli) -> ExitCode {
648651
} = test_entry;
649652

650653
if properties.is_none() {
651-
log::info!("new test entry: {test_path:?}")
654+
log::info!("new test entry: {test_entry_path:?}")
652655
}
653656

654657
if test_reported.is_empty() && using_reports {
655-
let test_path = &test_path;
656-
let msg = lazy_format!("no entries found in reports for {:?}", test_path);
658+
let test_entry_path = &test_entry_path;
659+
let msg =
660+
lazy_format!("no entries found in reports for {:?}", test_entry_path);
657661
match preset {
658662
ReportProcessingPreset::Merge => log::warn!("{msg}"),
659663
ReportProcessingPreset::ResetAll
@@ -691,7 +695,7 @@ fn run(cli: Cli) -> ExitCode {
691695
"this is an artifact of disjoint test runs"
692696
),
693697
skip,
694-
test_path,
698+
test_entry_path,
695699
platform,
696700
build_profile,
697701
);
@@ -714,7 +718,7 @@ fn run(cli: Cli) -> ExitCode {
714718
let subtest_name = SectionHeader(subtest_name);
715719
if subtests.contains_key(&subtest_name) {
716720
found_reconciliation_err = true;
717-
log::error!("internal error: duplicate test path {test_path:?}");
721+
log::error!("internal error: duplicate test path {test_entry_path:?}");
718722
}
719723

720724
let Entry {
@@ -747,7 +751,7 @@ fn run(cli: Cli) -> ExitCode {
747751
if subtests.is_empty() && properties == Default::default() {
748752
None
749753
} else {
750-
Some((test_path, (properties, subtests)))
754+
Some((test_entry_path, (properties, subtests)))
751755
}
752756
});
753757

@@ -756,9 +760,9 @@ fn run(cli: Cli) -> ExitCode {
756760
);
757761

758762
let mut files = BTreeMap::<PathBuf, File>::new();
759-
for (test_path, (properties, subtests)) in recombined_tests_iter {
760-
let name = test_path.test_name().to_string();
761-
let rel_path = Utf8PathBuf::from(test_path.rel_metadata_path().to_string());
763+
for (test_entry_path, (properties, subtests)) in recombined_tests_iter {
764+
let name = test_entry_path.test_name().to_string();
765+
let rel_path = Utf8PathBuf::from(test_entry_path.rel_metadata_path().to_string());
762766
let path = checkout.join(&rel_path);
763767
let file = files.entry(path).or_insert_with(|| File {
764768
properties: file_props_by_file
@@ -878,13 +882,13 @@ fn run(cli: Cli) -> ExitCode {
878882
let checkout = &checkout;
879883
move |(name, inner)| {
880884
let SectionHeader(name) = &name;
881-
let test_path = TestPath::from_metadata_test(
885+
let test_entry_path = TestEntryPath::from_metadata_test(
882886
browser,
883887
path.strip_prefix(checkout).unwrap(),
884888
name,
885889
)
886890
.unwrap();
887-
let url_path = test_path.runner_url_path().to_string();
891+
let url_path = test_entry_path.runner_url_path().to_string();
888892
(
889893
url_path,
890894
TaggedTest {

0 commit comments

Comments
 (0)