Skip to content

Commit

Permalink
WIP: feat: add update-backlog subcmd.
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed May 10, 2024
1 parent b16d8f4 commit 16eea71
Showing 1 changed file with 106 additions and 2 deletions.
108 changes: 106 additions & 2 deletions moz-webgpu-cts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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::<BTreeMap<_, _>>();
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 {

Check failure on line 1387 in moz-webgpu-cts/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

you seem to want to iterate on a map's values
// 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)) {

Check failure on line 1443 in moz-webgpu-cts/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler

Check failure on line 1443 in moz-webgpu-cts/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

this expression creates a reference which is immediately dereferenced by the compiler
Ok(()) => (),
Err(AlreadyReportedToCommandline) => found_write_err = true,
}
}
if found_write_err {
ExitCode::FAILURE
} else {
ExitCode::SUCCESS
}
}
}
}

Expand Down

0 comments on commit 16eea71

Please sign in to comment.