From 16eea71430fb0d5dddf4e090b17ab17b74bf2d00 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 7 May 2024 15:20:45 -0400 Subject: [PATCH] WIP: feat: add `update-backlog` subcmd. --- moz-webgpu-cts/src/main.rs | 108 ++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 2 deletions(-) diff --git a/moz-webgpu-cts/src/main.rs b/moz-webgpu-cts/src/main.rs index ff96e61..9defb44 100644 --- a/moz-webgpu-cts/src/main.rs +++ b/moz-webgpu-cts/src/main.rs @@ -5,8 +5,8 @@ mod shared; use self::{ metadata::{ - BuildProfile, File, FileProps, Platform, Subtest, SubtestOutcome, Test, TestOutcome, - TestProps, + BuildProfile, File, FileProps, ImplementationStatus, Platform, Subtest, SubtestOutcome, + Test, TestOutcome, TestProps, }, process_reports::{Entry, TestEntry}, report::{ @@ -99,6 +99,7 @@ enum Subcommand { #[clap(value_enum, long, default_value_t = Default::default())] on_zero_item: OnZeroItem, }, + UpdateBacklog, } #[derive(Clone, Copy, Debug, ValueEnum)] @@ -1347,6 +1348,109 @@ fn run(cli: Cli) -> ExitCode { println!("Full analysis: {analysis:#?}"); ExitCode::SUCCESS } + Subcommand::UpdateBacklog => { + let mut files = { + let mut found_parse_err = false; + let extracted = read_and_parse_all_metadata(&gecko_checkout) + .filter_map(|res| match res { + Ok(ok) => Some(ok), + Err(AlreadyReportedToCommandline) => { + found_parse_err = true; + None + } + }) + .collect::>(); + if found_parse_err { + log::error!(concat!( + "found one or more failures while parsing metadata, ", + "see above for more details" + )); + return ExitCode::FAILURE; + } + extracted + }; + + #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] + enum Case { + #[default] + PermaPass, + PermaFail, + Other, + } + let mut found_write_err = false; + for (file_path, file) in files.iter_mut() { + let File { + properties: _, + tests, + } = file; + + for (_name, test) in tests { + // let SectionHeader(name) = &name; + // let test_path = TestPath::from_fx_metadata_test( + // file_path.strip_prefix(gecko_checkout).unwrap(), + // name, + // ) + // .unwrap(); + let Test { + properties, + subtests, + } = test; + let mut cases = ExpandedPropertyValue::default(); + for ((platform, build_profile), expected) in properties + .expected + .as_ref() + .unwrap_or(&Default::default()) + .iter() + { + let case = match expected.as_permanent() { + Some(TestOutcome::Ok) => Case::PermaPass, + _ => Case::Other, + }; + cases[(platform, build_profile)] = case; + } + if !subtests.is_empty() { + cases = ExpandedPropertyValue::from_query(|platform, build_profile| { + let consistent_expected = subtests + .iter() + .map(|subtest| { + let (_name, Subtest { properties }) = subtest; + let expected = + properties.expected.as_ref().unwrap_or(&Default::default()) + [(platform, build_profile)]; + match expected.as_permanent() { + Some(SubtestOutcome::Pass) => Case::PermaPass, + Some(SubtestOutcome::Fail) => Case::PermaFail, + _ => Case::Other, + } + }) + .all_equal_value() + .ok(); + consistent_expected.unwrap_or(Case::Other) + }); + } + // TODO: Just compare this multiple times (here _and_ above), and compare + // subtests afterwards. + properties.implementation_status = if let Ok(Case::PermaPass) = + cases.into_iter().map(|(_, case)| case).all_equal_value() + { + None + } else { + Some(ExpandedPropertyValue::unconditional( + ImplementationStatus::Backlog, + )) + }; + } + match write_to_file(&file_path, metadata::format_file(&file)) { + Ok(()) => (), + Err(AlreadyReportedToCommandline) => found_write_err = true, + } + } + if found_write_err { + ExitCode::FAILURE + } else { + ExitCode::SUCCESS + } + } } }