Skip to content

Commit 3a5fb7e

Browse files
Merge pull request #124 from ErichDonGubler/push-oxqkttqzmlww
Split up the `shared` module into smaller ones with sensible names, also rename some `Test*` symbols
2 parents ce806d8 + 95531ed commit 3a5fb7e

8 files changed

Lines changed: 1003 additions & 988 deletions

File tree

moz-webgpu-cts/src/main.rs

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
mod metadata;
21
mod process_reports;
32
mod report;
4-
mod shared;
3+
mod wpt;
54

65
use self::{
7-
metadata::{
8-
BuildProfile, File, FileProps, Platform, Subtest, SubtestOutcome, Test, TestOutcome,
9-
TestProps,
10-
},
116
process_reports::{Entry, TestEntry},
127
report::{
138
ExecutionReport, RunInfo, SubtestExecutionResult, TestExecutionEntry, TestExecutionResult,
149
},
15-
shared::{ExpandedPropertyValue, Expected, TestPath},
10+
wpt::{
11+
metadata::{
12+
self,
13+
properties::{ExpandedPropertyValue, Expected},
14+
BuildProfile, File, FileProps, ImplementationStatus, Platform, Subtest, SubtestOutcome,
15+
Test, TestOutcome, TestProps,
16+
},
17+
path::TestEntryPath,
18+
},
1619
};
1720

1821
use std::{
@@ -31,18 +34,17 @@ use std::{
3134
},
3235
};
3336

37+
use crate::wpt::path::Browser;
3438
use camino::Utf8PathBuf;
3539
use clap::{Parser, ValueEnum};
3640
use enumset::EnumSetType;
3741
use format::lazy_format;
3842
use indexmap::{IndexMap, IndexSet};
3943
use itertools::Itertools;
4044
use joinery::JoinableIterator;
41-
use metadata::ImplementationStatus;
4245
use miette::{miette, Diagnostic, IntoDiagnostic, NamedSource, Report, SourceSpan, WrapErr};
4346
use path_dsl::path;
4447
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
45-
use shared::Browser;
4648
use wax::Glob;
4749
use whippit::{
4850
metadata::SectionHeader,
@@ -112,7 +114,7 @@ enum Subcommand {
112114
/// Identify and promote tests that are ready to come out of the `backlog` implementation
113115
/// status.
114116
UpdateBacklog {
115-
/// The heuristic to use for identifying tests that can be promoted.
117+
/// The mode to use for updating tests.
116118
preset: UpdateBacklogPreset,
117119
},
118120
/// Dump all metadata as JSON. Do so at your own risk; no guarantees are made about the
@@ -277,23 +279,23 @@ fn run(cli: Cli) -> ExitCode {
277279

278280
#[derive(Debug, Default)]
279281
struct EntryByCtsPath<'a> {
280-
metadata_path: Option<TestPath<'a>>,
281-
reported_path: Option<TestPath<'a>>,
282+
metadata_path: Option<TestEntryPath<'a>>,
283+
reported_path: Option<TestEntryPath<'a>>,
282284
entry: TestEntry,
283285
}
284286

285-
fn cts_path(test_path: &TestPath<'_>) -> Option<String> {
286-
test_path
287+
fn cts_path(test_entry_path: &TestEntryPath<'_>) -> Option<String> {
288+
test_entry_path
287289
.variant
288290
.as_ref()
289291
.filter(|v| v.starts_with("?q=webgpu:"))
290292
.map(|v| v.strip_prefix("?q=").unwrap().to_owned())
291-
.filter(|_q| test_path.path.ends_with("cts.https.html"))
293+
.filter(|_q| test_entry_path.path.ends_with("cts.https.html"))
292294
}
293295

294296
let mut file_props_by_file = IndexMap::<Utf8PathBuf, FileProps>::default();
295297
let mut entries_by_cts_path = IndexMap::<String, EntryByCtsPath<'_>>::default();
296-
let mut other_entries_by_test = IndexMap::<TestPath<'_>, TestEntry>::default();
298+
let mut other_entries_by_test = IndexMap::<TestEntryPath<'_>, TestEntry>::default();
297299
let old_meta_file_paths = meta_files_by_path.keys().cloned().collect::<Vec<_>>();
298300

299301
log::debug!("loading metadata for comparison to reports…");
@@ -313,8 +315,8 @@ fn run(cli: Cli) -> ExitCode {
313315
subtests,
314316
} = test;
315317

316-
let test_path =
317-
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();
318320

319321
let freak_out_do_nothing = |what: &dyn Display| {
320322
log::error!("hoo boy, not sure what to do yet: {what}")
@@ -329,7 +331,7 @@ fn run(cli: Cli) -> ExitCode {
329331
"discarding previous entries with ",
330332
"this and further dupes"
331333
),
332-
test_path
334+
test_entry_path
333335
))
334336
}
335337
reported_dupe_already = true;
@@ -338,21 +340,22 @@ fn run(cli: Cli) -> ExitCode {
338340
let TestEntry {
339341
entry: test_entry,
340342
subtests: subtest_entries,
341-
} = if let Some(cts_path) = cts_path(&test_path) {
343+
} = if let Some(cts_path) = cts_path(&test_entry_path) {
342344
let entry = entries_by_cts_path.entry(cts_path).or_default();
343-
if let Some(_old) =
344-
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())
345348
{
346349
dupe_err();
347350
}
348351
&mut entry.entry
349352
} else {
350353
other_entries_by_test
351-
.entry(test_path.clone().into_owned())
354+
.entry(test_entry_path.clone().into_owned())
352355
.or_default()
353356
};
354357

355-
let test_path = &test_path;
358+
let test_entry_path = &test_entry_path;
356359

357360
if let Some(_old) = test_entry.meta_props.replace(properties) {
358361
dupe_err();
@@ -370,7 +373,7 @@ fn run(cli: Cli) -> ExitCode {
370373
"discarding previous entries with ",
371374
"this and further dupes"
372375
),
373-
test_path, subtest_name
376+
test_entry_path, subtest_name
374377
));
375378
}
376379
}
@@ -443,16 +446,18 @@ fn run(cli: Cli) -> ExitCode {
443446
for entry in entries {
444447
let TestExecutionEntry { test_name, result } = entry;
445448

446-
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();
447451
let TestEntry {
448452
entry: test_entry,
449453
subtests: subtest_entries,
450-
} = if let Some(cts_path) = cts_path(&test_path) {
454+
} = if let Some(cts_path) = cts_path(&test_entry_path) {
451455
let entry = entries_by_cts_path.entry(cts_path).or_default();
452-
if let Some(old) =
453-
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())
454459
{
455-
if old != test_path {
460+
if old != test_entry_path {
456461
log::warn!(
457462
concat!(
458463
"found test execution entry containing the same ",
@@ -463,14 +468,14 @@ fn run(cli: Cli) -> ExitCode {
463468
"newer: {:#?}\n",
464469
),
465470
old,
466-
test_path
471+
test_entry_path
467472
)
468473
}
469474
}
470475
&mut entry.entry
471476
} else {
472477
other_entries_by_test
473-
.entry(test_path.clone().into_owned())
478+
.entry(test_entry_path.clone().into_owned())
474479
.or_default()
475480
};
476481

@@ -483,7 +488,7 @@ fn run(cli: Cli) -> ExitCode {
483488
"expected an empty `status` field for {:?}, ",
484489
"but found the {:?} status"
485490
),
486-
test_path,
491+
test_entry_path,
487492
status,
488493
)
489494
}
@@ -573,7 +578,7 @@ fn run(cli: Cli) -> ExitCode {
573578
});
574579
let recombined_tests_iter = entries_by_cts_path
575580
.chain(other_entries_by_test)
576-
.filter_map(|(test_path, test_entry)| {
581+
.filter_map(|(test_entry_path, test_entry)| {
577582
/// Reconciles `meta_props` with `reported` if they match
578583
/// `implementation_status_filter`.
579584
///
@@ -646,12 +651,13 @@ fn run(cli: Cli) -> ExitCode {
646651
} = test_entry;
647652

648653
if properties.is_none() {
649-
log::info!("new test entry: {test_path:?}")
654+
log::info!("new test entry: {test_entry_path:?}")
650655
}
651656

652657
if test_reported.is_empty() && using_reports {
653-
let test_path = &test_path;
654-
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);
655661
match preset {
656662
ReportProcessingPreset::Merge => log::warn!("{msg}"),
657663
ReportProcessingPreset::ResetAll
@@ -689,7 +695,7 @@ fn run(cli: Cli) -> ExitCode {
689695
"this is an artifact of disjoint test runs"
690696
),
691697
skip,
692-
test_path,
698+
test_entry_path,
693699
platform,
694700
build_profile,
695701
);
@@ -712,7 +718,7 @@ fn run(cli: Cli) -> ExitCode {
712718
let subtest_name = SectionHeader(subtest_name);
713719
if subtests.contains_key(&subtest_name) {
714720
found_reconciliation_err = true;
715-
log::error!("internal error: duplicate test path {test_path:?}");
721+
log::error!("internal error: duplicate test path {test_entry_path:?}");
716722
}
717723

718724
let Entry {
@@ -745,7 +751,7 @@ fn run(cli: Cli) -> ExitCode {
745751
if subtests.is_empty() && properties == Default::default() {
746752
None
747753
} else {
748-
Some((test_path, (properties, subtests)))
754+
Some((test_entry_path, (properties, subtests)))
749755
}
750756
});
751757

@@ -754,9 +760,9 @@ fn run(cli: Cli) -> ExitCode {
754760
);
755761

756762
let mut files = BTreeMap::<PathBuf, File>::new();
757-
for (test_path, (properties, subtests)) in recombined_tests_iter {
758-
let name = test_path.test_name().to_string();
759-
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());
760766
let path = checkout.join(&rel_path);
761767
let file = files.entry(path).or_insert_with(|| File {
762768
properties: file_props_by_file
@@ -876,13 +882,13 @@ fn run(cli: Cli) -> ExitCode {
876882
let checkout = &checkout;
877883
move |(name, inner)| {
878884
let SectionHeader(name) = &name;
879-
let test_path = TestPath::from_metadata_test(
885+
let test_entry_path = TestEntryPath::from_metadata_test(
880886
browser,
881887
path.strip_prefix(checkout).unwrap(),
882888
name,
883889
)
884890
.unwrap();
885-
let url_path = test_path.runner_url_path().to_string();
891+
let url_path = test_entry_path.runner_url_path().to_string();
886892
(
887893
url_path,
888894
TaggedTest {

moz-webgpu-cts/src/process_reports.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::collections::BTreeMap;
22

33
use enumset::EnumSetType;
44

5-
use crate::{
6-
metadata::{BuildProfile, Platform, SubtestOutcome, TestOutcome, TestProps},
7-
shared::Expected,
5+
use crate::wpt::metadata::{
6+
properties::Expected, BuildProfile, Platform, SubtestOutcome, TestOutcome, TestProps,
87
};
98

109
#[derive(Debug, Default)]

0 commit comments

Comments
 (0)