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 Apr 16, 2024
1 parent 3caa75a commit ef6b6ee
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
105 changes: 105 additions & 0 deletions moz-webgpu-cts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ enum Subcommand {
#[clap(value_enum, long, default_value_t = Default::default())]
on_zero_item: OnZeroItem,
},
MarkBacklog,
}

#[derive(Clone, Copy, Debug, ValueEnum)]
Expand Down Expand Up @@ -1411,6 +1412,110 @@ fn run(cli: Cli) -> ExitCode {
println!("Full analysis: {analysis:#?}");
ExitCode::SUCCESS
}
Subcommand::MarkBacklog => {
let tests_by_name = {
let mut found_parse_err = false;
let raw_test_files_by_path = match read_metadata() {
Ok(paths) => paths,
Err(AlreadyReportedToCommandline) => return ExitCode::FAILURE,
};
let extracted = raw_test_files_by_path
.iter()
.filter_map(|(path, file_contents)| {
match chumsky::Parser::parse(&metadata::File::parser(), file_contents)
.into_result()
{
Ok(File {
properties: _,
tests,
}) => Some(tests.into_iter().map({
let gecko_checkout = &gecko_checkout;
move |(name, test)| {
let SectionHeader(name) = &name;
let test_path = TestPath::from_fx_metadata_test(
path.strip_prefix(gecko_checkout).unwrap(),
name,
)
.unwrap();
(test_path.into_owned(), test)
}
})),
Err(errors) => {
found_parse_err = true;
render_metadata_parse_errors(path, file_contents, errors);
None
}
}
})
.flatten()
.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,
}
println!("file\ttest\tsubtest");
for (test_path, test) in tests_by_name.iter() {
let Test {
properties,
subtests,
} = test;
if subtests.is_empty() {
let prop = properties
.expectations
.as_ref()
.map(|exps| {
exps.map_ref(|exps| match exps.as_permanent() {

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

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

no method named `map_ref` found for reference `&FullyExpandedExpectationPropertyValue<TestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Clippy (stable)

no method named `map_ref` found for reference `&shared::FullyExpandedExpectationPropertyValue<metadata::TestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, beta)

no method named `map_ref` found for reference `&FullyExpandedExpectationPropertyValue<TestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no method named `map_ref` found for reference `&shared::FullyExpandedExpectationPropertyValue<metadata::TestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, beta)

no method named `map_ref` found for reference `&FullyExpandedExpectationPropertyValue<TestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, stable)

no method named `map_ref` found for reference `&FullyExpandedExpectationPropertyValue<TestOutcome>` in the current scope
Some(TestOutcome::Ok) => Case::PermaPass,
_ => Case::Other,
})
})
.unwrap_or_default();
if prop == Default::default() {
println!(
"{}\t{}\t",
test_path.rel_metadata_path_fx(),
test_path.test_name()
);
}
} else {
for (subtest_name, subtest) in subtests {
let Subtest { properties } = subtest;
let prop = properties
.expectations
.as_ref()
.map(|exps| {
exps.map_ref(|exps| match exps.as_permanent() {

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

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

no method named `map_ref` found for reference `&FullyExpandedExpectationPropertyValue<SubtestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Clippy (stable)

no method named `map_ref` found for reference `&shared::FullyExpandedExpectationPropertyValue<metadata::SubtestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, beta)

no method named `map_ref` found for reference `&FullyExpandedExpectationPropertyValue<SubtestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no method named `map_ref` found for reference `&shared::FullyExpandedExpectationPropertyValue<metadata::SubtestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, beta)

no method named `map_ref` found for reference `&FullyExpandedExpectationPropertyValue<SubtestOutcome>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest, stable)

no method named `map_ref` found for reference `&FullyExpandedExpectationPropertyValue<SubtestOutcome>` in the current scope
Some(SubtestOutcome::Pass) => Case::PermaPass,
Some(SubtestOutcome::Fail) => Case::PermaFail,
_ => Case::Other,
})
})
.unwrap_or_default();
if prop == Default::default() {
println!(
"{}\t{}\t{subtest_name:?}",
test_path.rel_metadata_path_fx(),
test_path.test_name(),
);
}
}
}
}
ExitCode::SUCCESS
}
}
}

Expand Down
26 changes: 26 additions & 0 deletions moz-webgpu-cts/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,22 @@ impl<K, V> MaybeCollapsed<V, BTreeMap<K, V>> {
MaybeCollapsed::Expanded(exp) => exp.get(key),
}
}

fn map_ref_normalized<T, F>(&self, f: F) -> MaybeCollapsed<T, BTreeMap<K, T>>
where
K: Clone + IntoEnumIterator + Ord,
T: Clone + Default + Eq,
F: FnMut(&V) -> T,
{
let mut f = f;
match self {
MaybeCollapsed::Collapsed(coll) => MaybeCollapsed::Collapsed(f(coll)),
MaybeCollapsed::Expanded(exp) => {
let new_values = exp.iter().map(|(k, v)| (k.clone(), f(v))).collect();
normalize(new_values, std::convert::identity)
}
}
}
}

impl<C, E> Default for MaybeCollapsed<C, E>
Expand Down Expand Up @@ -444,6 +460,16 @@ where
.copied()
.unwrap_or_default()
}

pub fn map_ref<T, F>(&self, f: F) -> NormalizedPropertyValueData<T>
where
T: Clone + Default + Eq,
F: FnMut(&Expectation<Out>) -> T,
{
let mut f = f;
self.inner()
.map_ref_normalized(|exps| exps.map_ref_normalized(|exps| f(exps)))
}
}

fn normalize<K, V, T, F>(mut map: BTreeMap<K, V>, mut f: F) -> MaybeCollapsed<T, BTreeMap<K, T>>
Expand Down

0 comments on commit ef6b6ee

Please sign in to comment.