Skip to content

Commit

Permalink
WIP: feat(process_reports): add reset-contradictory preset
Browse files Browse the repository at this point in the history
TODO: realign name
  • Loading branch information
ErichDonGubler committed Nov 1, 2023
1 parent 0ab09fe commit e7f7505
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 5 deletions.
64 changes: 59 additions & 5 deletions moz-webgpu-cts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use self::{
report::{
ExecutionReport, RunInfo, SubtestExecutionResult, TestExecutionEntry, TestExecutionResult,
},
shared::{Expectation, MaybeCollapsed, TestPath},
shared::{Expectation, MaybeCollapsed, NormalizedExpectationPropertyValue, TestPath},
};

use std::{
Expand All @@ -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};

Expand Down Expand Up @@ -69,6 +70,7 @@ enum Subcommand {

#[derive(Clone, Copy, Debug, ValueEnum)]
enum ReportProcessingPreset {
ResetContradictory,
ResetAll,
}

Expand Down Expand Up @@ -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,
Expand Down
28 changes: 28 additions & 0 deletions moz-webgpu-cts/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ where
pub fn iter(&self) -> impl Iterator<Item = Out> {
self.inner().iter()
}

pub fn is_superset(&self, rep: &Expectation<Out>) -> bool
where
Out: std::fmt::Debug + Default + EnumSetType,
{
self.inner().is_superset(*rep.inner())
}
}

impl<Out> Display for Expectation<Out>
Expand Down Expand Up @@ -290,6 +297,27 @@ where
normalize(by_build_profile, std::convert::identity)
}))
}

pub fn get(&self, platform: Platform, build_profile: BuildProfile) -> Expectation<Out>
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.
Expand Down

0 comments on commit e7f7505

Please sign in to comment.