Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use flat repr. for full outcome sets (i.e., metadata), unify language in missing entry diagnostic #84

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions moz-webgpu-cts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ strum = { version = "0.25.0", features = ["derive"] }
thiserror = { workspace = true }
wax = { version = "0.6.0", features = ["miette"], git = "https://github.com/ErichDonGubler/wax", branch = "static-miette-diags"}
whippit = { version = "0.6.0", path = "../whippit", default-features = false }
enum-map = "2.7.3"

[dev-dependencies]
insta = { workspace = true }
147 changes: 36 additions & 111 deletions moz-webgpu-cts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use self::{
report::{
ExecutionReport, RunInfo, SubtestExecutionResult, TestExecutionEntry, TestExecutionResult,
},
shared::{Expectation, MaybeCollapsed, NormalizedExpectationPropertyValue, TestPath},
shared::{Expectation, FullyExpandedExpectationPropertyValue, TestPath},
};

use std::{
Expand All @@ -35,7 +35,6 @@ use joinery::JoinableIterator;
use miette::{miette, Diagnostic, IntoDiagnostic, NamedSource, Report, SourceSpan, WrapErr};
use path_dsl::path;
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
use strum::IntoEnumIterator;
use wax::Glob;
use whippit::{
metadata::SectionHeader,
Expand Down Expand Up @@ -515,7 +514,7 @@ fn run(cli: Cli) -> ExitCode {
build_profile: BuildProfile,
reported_outcome: Out,
) where
Out: EnumSetType + Hash,
Out: Default + EnumSetType + Hash,
{
match recorded.entry(platform).or_default().entry(build_profile) {
std::collections::btree_map::Entry::Vacant(entry) => {
Expand Down Expand Up @@ -603,13 +602,25 @@ fn run(cli: Cli) -> ExitCode {
meta_props,
reported,
} = entry;
let normalize = NormalizedExpectationPropertyValue::from_fully_expanded;

let mut meta_props = meta_props.unwrap_or_default();
meta_props.expectations = Some('resolve: {
let reported = |platform, build_profile| {
reported
.get(&platform)
.and_then(|rep| rep.get(&build_profile))
.copied()
};
let all_reported = || {
FullyExpandedExpectationPropertyValue::from_query(
|platform, build_profile| {
reported(platform, build_profile).unwrap_or_default()
},
)
};
let resolve = match preset {
ReportProcessingPreset::ResetAll => {
break 'resolve normalize(reported);
break 'resolve all_reported();
}
ReportProcessingPreset::ResetContradictory => {
|meta: Expectation<_>, rep: Option<Expectation<_>>| {
Expand All @@ -622,31 +633,18 @@ fn run(cli: Cli) -> ExitCode {
},
};

normalize(
Platform::iter()
.map(|platform| {
let build_profiles = BuildProfile::iter()
.map(|build_profile| {
(
build_profile,
resolve(
meta_props
.expectations
.as_ref()
.unwrap_or(&Default::default())
.get(platform, build_profile),
reported
.get(&platform)
.and_then(|rep| rep.get(&build_profile))
.copied(),
),
)
})
.collect();
(platform, build_profiles)
})
.collect(),
)
if let Some(meta_expectations) = meta_props.expectations {
FullyExpandedExpectationPropertyValue::from_query(
|platform, build_profile| {
resolve(
meta_expectations.get(platform, build_profile),
reported(platform, build_profile),
)
},
)
} else {
all_reported()
}
});
meta_props
}
Expand All @@ -661,16 +659,13 @@ fn run(cli: Cli) -> ExitCode {
}

if test_entry.reported.is_empty() {
let test_path = &test_path;
let msg = lazy_format!("no entries found in reports for {:?}", test_path);
match preset {
ReportProcessingPreset::Merge => {
log::warn!("no entries found in reports for {test_path:?}")
}
ReportProcessingPreset::Merge => log::warn!("{msg}"),
ReportProcessingPreset::ResetAll
| ReportProcessingPreset::ResetContradictory => {
log::warn!(
"removing entry after finding no entries in reports: {:?}",
test_path
);
log::warn!("removing metadata after {msg}");
return None;
}
}
Expand Down Expand Up @@ -1091,48 +1086,15 @@ fn run(cli: Cli) -> ExitCode {
}
}

let apply_to_all_platforms = |analysis: &mut Analysis, expectation| {
analyze_test_outcome(&test_name, expectation, |f| {
analysis.for_each_platform_mut(f)
})
};
let apply_to_specific_platforms =
|analysis: &mut Analysis, platform, expectation| {
analyze_test_outcome(&test_name, expectation, |f| {
analysis.for_platform_mut(platform, f)
})
};

match expectations.into_inner() {
MaybeCollapsed::Collapsed(exps) => match exps {
MaybeCollapsed::Collapsed(exp) => {
apply_to_all_platforms(&mut analysis, exp)
}
MaybeCollapsed::Expanded(by_build_profile) => {
for (_build_profile, exp) in by_build_profile {
apply_to_all_platforms(&mut analysis, exp)
}
}
},
MaybeCollapsed::Expanded(by_platform) => {
for (platform, exp_by_build_profile) in by_platform {
// TODO: has a lot in common with above cases. Refactor out?
match exp_by_build_profile {
MaybeCollapsed::Collapsed(exp) => {
apply_to_specific_platforms(&mut analysis, platform, exp)
}
MaybeCollapsed::Expanded(by_build_profile) => {
for (_build_profile, exp) in by_build_profile {
apply_to_specific_platforms(
&mut analysis,
platform,
exp,
)
}
}
}
}
}
for ((platform, _build_profile), expectations) in expectations.iter() {
apply_to_specific_platforms(&mut analysis, platform, expectations)
}
}

Expand Down Expand Up @@ -1198,11 +1160,6 @@ fn run(cli: Cli) -> ExitCode {
}
}

let apply_to_all_platforms = |analysis: &mut Analysis, expectation| {
analyze_subtest_outcome(&test_name, &subtest_name, expectation, |f| {
analysis.for_each_platform_mut(f)
})
};
let apply_to_specific_platforms =
|analysis: &mut Analysis, platform, expectation| {
analyze_subtest_outcome(
Expand All @@ -1213,40 +1170,8 @@ fn run(cli: Cli) -> ExitCode {
)
};

match expectations.into_inner() {
MaybeCollapsed::Collapsed(exps) => match exps {
MaybeCollapsed::Collapsed(exp) => {
apply_to_all_platforms(&mut analysis, exp)
}
MaybeCollapsed::Expanded(by_build_profile) => {
for (_build_profile, exp) in by_build_profile {
apply_to_all_platforms(&mut analysis, exp)
}
}
},
MaybeCollapsed::Expanded(by_platform) => {
for (platform, exp_by_build_profile) in by_platform {
// TODO: has a lot in common with above cases. Refactor out?
match exp_by_build_profile {
MaybeCollapsed::Collapsed(exp) => {
apply_to_specific_platforms(
&mut analysis,
platform,
exp,
)
}
MaybeCollapsed::Expanded(by_build_profile) => {
for (_build_profile, exp) in by_build_profile {
apply_to_specific_platforms(
&mut analysis,
platform,
exp,
)
}
}
}
}
}
for ((platform, _build_profile), expectations) in expectations.iter() {
apply_to_specific_platforms(&mut analysis, platform, expectations)
}
}
}
Expand Down
Loading
Loading