From 39efc19f9becd84d968083009c4d377e98e10a89 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Fri, 7 Jun 2024 10:37:45 -0400 Subject: [PATCH 1/5] refactor(update_expected): s/properties/subtest_properties/ --- moz-webgpu-cts/src/main.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/moz-webgpu-cts/src/main.rs b/moz-webgpu-cts/src/main.rs index 07f8ab10..27bf4aeb 100644 --- a/moz-webgpu-cts/src/main.rs +++ b/moz-webgpu-cts/src/main.rs @@ -675,17 +675,24 @@ fn run(cli: Cli) -> ExitCode { } let Entry { - meta_props: properties, + meta_props: subtest_properties, reported: subtest_reported, } = subtest; - let mut properties = properties.unwrap_or_default(); - reconcile(&mut properties, subtest_reported, preset); - for (_, expected) in properties.expected.as_mut().unwrap().iter_mut() { + let mut subtest_properties = subtest_properties.unwrap_or_default(); + reconcile(&mut subtest_properties, subtest_reported, preset); + for (_, expected) in + subtest_properties.expected.as_mut().unwrap().iter_mut() + { taint_subtest_timeouts_by_suspicion(expected); } - subtests.insert(subtest_name, Subtest { properties }); + subtests.insert( + subtest_name, + Subtest { + properties: subtest_properties, + }, + ); } if subtests.is_empty() && properties == Default::default() { From 411763ea848b490d2e07ef475e81889b10d704a6 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Fri, 7 Jun 2024 15:00:31 -0400 Subject: [PATCH 2/5] refactor(update_expected): move `resolve` inward --- moz-webgpu-cts/src/main.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/moz-webgpu-cts/src/main.rs b/moz-webgpu-cts/src/main.rs index 27bf4aeb..63bf23ba 100644 --- a/moz-webgpu-cts/src/main.rs +++ b/moz-webgpu-cts/src/main.rs @@ -572,22 +572,22 @@ fn run(cli: Cli) -> ExitCode { reported(platform, build_profile).unwrap_or_default() }) }; - let resolve = match preset { - ReportProcessingPreset::ResetAll => { - break 'resolve all_reported(); - } - ReportProcessingPreset::ResetContradictory => { - |meta: Expected<_>, rep: Option>| { - rep.filter(|rep| !meta.is_superset(rep)).unwrap_or(meta) + if let Some(meta_expected) = meta_props.expected { + let resolve = match preset { + ReportProcessingPreset::ResetAll => { + break 'resolve all_reported(); } - } - ReportProcessingPreset::Merge => |meta, rep| match rep { - Some(rep) => meta | rep, - None => meta, - }, - }; + ReportProcessingPreset::ResetContradictory => { + |meta: Expected<_>, rep: Option>| { + rep.filter(|rep| !meta.is_superset(rep)).unwrap_or(meta) + } + } + ReportProcessingPreset::Merge => |meta, rep| match rep { + Some(rep) => meta | rep, + None => meta, + }, + }; - if let Some(meta_expected) = meta_props.expected { ExpandedPropertyValue::from_query(|platform, build_profile| { resolve( meta_expected[(platform, build_profile)], From b4d19bf39910578d37b2273609253c0c7464b80a Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Fri, 7 Jun 2024 15:14:32 -0400 Subject: [PATCH 3/5] refactor(update_expected): inline `all_reported` --- moz-webgpu-cts/src/main.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/moz-webgpu-cts/src/main.rs b/moz-webgpu-cts/src/main.rs index 63bf23ba..5ff00a71 100644 --- a/moz-webgpu-cts/src/main.rs +++ b/moz-webgpu-cts/src/main.rs @@ -560,22 +560,17 @@ fn run(cli: Cli) -> ExitCode { ) where Out: Debug + Default + EnumSetType, { - let reconciled = 'resolve: { + let reconciled = { let reported = |platform, build_profile| { reported .get(&platform) .and_then(|rep| rep.get(&build_profile)) .copied() }; - let all_reported = || { - ExpandedPropertyValue::from_query(|platform, build_profile| { - reported(platform, build_profile).unwrap_or_default() - }) - }; if let Some(meta_expected) = meta_props.expected { let resolve = match preset { ReportProcessingPreset::ResetAll => { - break 'resolve all_reported(); + |_meta, rep: Option<_>| rep.unwrap_or_default() } ReportProcessingPreset::ResetContradictory => { |meta: Expected<_>, rep: Option>| { @@ -595,7 +590,9 @@ fn run(cli: Cli) -> ExitCode { ) }) } else { - all_reported() + ExpandedPropertyValue::from_query(|platform, build_profile| { + reported(platform, build_profile).unwrap_or_default() + }) } }; meta_props.expected = Some(reconciled); From 3a0e655842d62664ec3716b7d476cf223320f4ab Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Fri, 7 Jun 2024 15:16:06 -0400 Subject: [PATCH 4/5] refactor(update_expected): make args. to `reported` a tuple --- moz-webgpu-cts/src/main.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/moz-webgpu-cts/src/main.rs b/moz-webgpu-cts/src/main.rs index 5ff00a71..2fe874c4 100644 --- a/moz-webgpu-cts/src/main.rs +++ b/moz-webgpu-cts/src/main.rs @@ -561,7 +561,7 @@ fn run(cli: Cli) -> ExitCode { Out: Debug + Default + EnumSetType, { let reconciled = { - let reported = |platform, build_profile| { + let reported = |(platform, build_profile)| { reported .get(&platform) .and_then(|rep| rep.get(&build_profile)) @@ -584,14 +584,12 @@ fn run(cli: Cli) -> ExitCode { }; ExpandedPropertyValue::from_query(|platform, build_profile| { - resolve( - meta_expected[(platform, build_profile)], - reported(platform, build_profile), - ) + let key = (platform, build_profile); + resolve(meta_expected[key], reported(key)) }) } else { ExpandedPropertyValue::from_query(|platform, build_profile| { - reported(platform, build_profile).unwrap_or_default() + reported((platform, build_profile)).unwrap_or_default() }) } }; From 461ec0d14c2091ad81eceae44798203140653ab9 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Fri, 7 Jun 2024 15:22:24 -0400 Subject: [PATCH 5/5] =?UTF-8?q?feat(update=5Fexpected):=20add=20`--impleme?= =?UTF-8?q?ntation-status=3D=E2=80=A6`=20filter=20defaulting=20to=20`backl?= =?UTF-8?q?og`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- moz-webgpu-cts/src/main.rs | 42 +++++++++++++++++++++++++++++++--- moz-webgpu-cts/src/metadata.rs | 3 ++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/moz-webgpu-cts/src/main.rs b/moz-webgpu-cts/src/main.rs index 2fe874c4..885633e4 100644 --- a/moz-webgpu-cts/src/main.rs +++ b/moz-webgpu-cts/src/main.rs @@ -38,6 +38,7 @@ use format::lazy_format; use indexmap::{IndexMap, IndexSet}; use itertools::Itertools; use joinery::JoinableIterator; +use metadata::ImplementationStatus; use miette::{miette, Diagnostic, IntoDiagnostic, NamedSource, Report, SourceSpan, WrapErr}; use path_dsl::path; use rayon::prelude::{IntoParallelIterator, ParallelIterator}; @@ -97,6 +98,9 @@ enum Subcommand { /// The heuristic for resolving differences between current metadata and processed reports. #[clap(long, default_value = "reset-contradictory")] preset: ReportProcessingPreset, + /// The `implementation-status` that changes should be applied to. + #[clap(value_enum, long, default_value_t = ImplementationStatus::Backlog)] + implementation_status: ImplementationStatus, }, /// Parse test metadata, apply automated fixups, and re-emit it in normalized form. #[clap(name = "fixup", alias = "fmt")] @@ -167,6 +171,7 @@ fn run(cli: Cli) -> ExitCode { report_globs, report_paths, preset, + implementation_status, } => { let report_globs = { let mut found_glob_parse_err = false; @@ -553,13 +558,28 @@ fn run(cli: Cli) -> ExitCode { let recombined_tests_iter = entries_by_cts_path .chain(other_entries_by_test) .filter_map(|(test_path, test_entry)| { + /// Reconciles `meta_props` with `reported` if they match + /// `implementation_status_filter`. + /// + /// For subtests, `parent_implementation_status` should be specified so the + /// parent test's implementation status can be used for filtering. fn reconcile( + parent_implementation_status: Option< + &ExpandedPropertyValue, + >, meta_props: &mut TestProps, reported: BTreeMap>>, preset: ReportProcessingPreset, + implementation_status_filter: ImplementationStatus, ) where Out: Debug + Default + EnumSetType, { + let implementation_status = meta_props + .implementation_status + .or(parent_implementation_status.cloned()) + .unwrap_or_default(); + let should_apply_changes = + |key| implementation_status[key] == implementation_status_filter; let reconciled = { let reported = |(platform, build_profile)| { reported @@ -585,7 +605,11 @@ fn run(cli: Cli) -> ExitCode { ExpandedPropertyValue::from_query(|platform, build_profile| { let key = (platform, build_profile); - resolve(meta_expected[key], reported(key)) + if should_apply_changes(key) { + resolve(meta_expected[key], reported(key)) + } else { + meta_expected[key] + } }) } else { ExpandedPropertyValue::from_query(|platform, build_profile| { @@ -659,7 +683,13 @@ fn run(cli: Cli) -> ExitCode { } } - reconcile(&mut properties, test_reported, preset); + reconcile( + None, + &mut properties, + test_reported, + preset, + implementation_status, + ); let mut subtests = BTreeMap::new(); for (subtest_name, subtest) in subtest_entries { @@ -675,7 +705,13 @@ fn run(cli: Cli) -> ExitCode { } = subtest; let mut subtest_properties = subtest_properties.unwrap_or_default(); - reconcile(&mut subtest_properties, subtest_reported, preset); + reconcile( + properties.implementation_status.as_ref(), + &mut subtest_properties, + subtest_reported, + preset, + implementation_status, + ); for (_, expected) in subtest_properties.expected.as_mut().unwrap().iter_mut() { diff --git a/moz-webgpu-cts/src/metadata.rs b/moz-webgpu-cts/src/metadata.rs index c7b3b2e3..8c1c0635 100644 --- a/moz-webgpu-cts/src/metadata.rs +++ b/moz-webgpu-cts/src/metadata.rs @@ -4,6 +4,7 @@ use std::{ hash::Hash, }; +use clap::ValueEnum; use enum_map::Enum; use enumset::EnumSetType; use format::lazy_format; @@ -562,7 +563,7 @@ fn format_file_properties(props: &FileProps) -> impl Display + '_ { }) } -#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, ValueEnum)] pub enum ImplementationStatus { /// Indicates that functionality governing test(s) is implemented or currently being /// implemented, and generally expected to conform to tests.