From e7f7505ef1edf19b1c36a671e0f39d82ae3cf8c9 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Wed, 1 Nov 2023 15:54:42 -0400 Subject: [PATCH] WIP: feat(process_reports): add `reset-contradictory` preset TODO: realign name --- moz-webgpu-cts/src/main.rs | 64 +++++++++++++++++++++++++++++++++--- moz-webgpu-cts/src/shared.rs | 28 ++++++++++++++++ 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/moz-webgpu-cts/src/main.rs b/moz-webgpu-cts/src/main.rs index 074437b..2b35c9f 100644 --- a/moz-webgpu-cts/src/main.rs +++ b/moz-webgpu-cts/src/main.rs @@ -11,7 +11,7 @@ use self::{ report::{ ExecutionReport, RunInfo, SubtestExecutionResult, TestExecutionEntry, TestExecutionResult, }, - shared::{Expectation, MaybeCollapsed, TestPath}, + shared::{Expectation, MaybeCollapsed, NormalizedExpectationPropertyValue, TestPath}, }; use std::{ @@ -33,6 +33,7 @@ use miette::{miette, Diagnostic, IntoDiagnostic, NamedSource, Report, SourceSpan use path_dsl::path; use rayon::prelude::{IntoParallelIterator, ParallelIterator}; use regex::Regex; +use strum::IntoEnumIterator; use wax::Glob; use whippit::{metadata::SectionHeader, reexport::chumsky::prelude::Rich}; @@ -69,6 +70,7 @@ enum Subcommand { #[derive(Clone, Copy, Debug, ValueEnum)] enum ReportProcessingPreset { + ResetContradictory, ResetAll, } @@ -490,10 +492,62 @@ fn run(cli: Cli) -> ExitCode { Out: Debug + Default + EnumSetType, { let (metadata, reported) = outcomes.into_normalized(); - let reconciled_expectations = - metadata.map_enabled(|_metadata| match preset { - ReportProcessingPreset::ResetAll => reported, - }); + let reconciled_expectations = metadata.map_enabled(|metadata| { + let resolve = match preset { + ReportProcessingPreset::ResetAll => return reported, + ReportProcessingPreset::ResetContradictory => { + |meta: Expectation<_>, rep: _| { + if meta.is_superset(&rep) { + meta + } else { + rep + } + } + } + }; + + if metadata == reported { + reported + } else { + use MaybeCollapsed::*; + + let normalize_full = + NormalizedExpectationPropertyValue::from_fully_expanded; + + match (metadata.inner(), reported.inner()) { + (Collapsed(Collapsed(meta)), Collapsed(Collapsed(rep))) => { + NormalizedExpectationPropertyValue::uniform(resolve( + *meta, *rep, + )) + } + _ => normalize_full( + Platform::iter() + .map(|platform| { + let build_profiles = BuildProfile::iter() + .map(|build_profile| { + ( + build_profile, + resolve( + metadata.get( + platform, + build_profile, + ), + reported.get( + platform, + build_profile, + ), + ), + ) + }) + .collect(); + (platform, build_profiles) + }) + .collect(), + ), + } + } + }); + match reconciled_expectations { MaybeDisabled::Disabled => AnalyzeableProps { is_disabled: true, diff --git a/moz-webgpu-cts/src/shared.rs b/moz-webgpu-cts/src/shared.rs index 566202b..a51b8ee 100644 --- a/moz-webgpu-cts/src/shared.rs +++ b/moz-webgpu-cts/src/shared.rs @@ -87,6 +87,13 @@ where pub fn iter(&self) -> impl Iterator { self.inner().iter() } + + pub fn is_superset(&self, rep: &Expectation) -> bool + where + Out: std::fmt::Debug + Default + EnumSetType, + { + self.inner().is_superset(*rep.inner()) + } } impl Display for Expectation @@ -290,6 +297,27 @@ where normalize(by_build_profile, std::convert::identity) })) } + + pub fn get(&self, platform: Platform, build_profile: BuildProfile) -> Expectation + where + Out: Default, + { + match self.inner() { + MaybeCollapsed::Collapsed(exps) => match exps { + MaybeCollapsed::Collapsed(exps) => *exps, + MaybeCollapsed::Expanded(exps) => { + exps.get(&build_profile).copied().unwrap_or_default() + } + }, + MaybeCollapsed::Expanded(exps) => exps + .get(&platform) + .and_then(|exps| match exps { + MaybeCollapsed::Collapsed(exps) => Some(*exps), + MaybeCollapsed::Expanded(exps) => exps.get(&build_profile).copied(), + }) + .unwrap_or_default(), + } + } } /// A single symbolic path to a test and its metadata.