Skip to content

Commit 461ec0d

Browse files
feat(update_expected): add --implementation-status=… filter defaulting to backlog
1 parent 3a0e655 commit 461ec0d

2 files changed

Lines changed: 41 additions & 4 deletions

File tree

moz-webgpu-cts/src/main.rs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use format::lazy_format;
3838
use indexmap::{IndexMap, IndexSet};
3939
use itertools::Itertools;
4040
use joinery::JoinableIterator;
41+
use metadata::ImplementationStatus;
4142
use miette::{miette, Diagnostic, IntoDiagnostic, NamedSource, Report, SourceSpan, WrapErr};
4243
use path_dsl::path;
4344
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
@@ -97,6 +98,9 @@ enum Subcommand {
9798
/// The heuristic for resolving differences between current metadata and processed reports.
9899
#[clap(long, default_value = "reset-contradictory")]
99100
preset: ReportProcessingPreset,
101+
/// The `implementation-status` that changes should be applied to.
102+
#[clap(value_enum, long, default_value_t = ImplementationStatus::Backlog)]
103+
implementation_status: ImplementationStatus,
100104
},
101105
/// Parse test metadata, apply automated fixups, and re-emit it in normalized form.
102106
#[clap(name = "fixup", alias = "fmt")]
@@ -167,6 +171,7 @@ fn run(cli: Cli) -> ExitCode {
167171
report_globs,
168172
report_paths,
169173
preset,
174+
implementation_status,
170175
} => {
171176
let report_globs = {
172177
let mut found_glob_parse_err = false;
@@ -553,13 +558,28 @@ fn run(cli: Cli) -> ExitCode {
553558
let recombined_tests_iter = entries_by_cts_path
554559
.chain(other_entries_by_test)
555560
.filter_map(|(test_path, test_entry)| {
561+
/// Reconciles `meta_props` with `reported` if they match
562+
/// `implementation_status_filter`.
563+
///
564+
/// For subtests, `parent_implementation_status` should be specified so the
565+
/// parent test's implementation status can be used for filtering.
556566
fn reconcile<Out>(
567+
parent_implementation_status: Option<
568+
&ExpandedPropertyValue<ImplementationStatus>,
569+
>,
557570
meta_props: &mut TestProps<Out>,
558571
reported: BTreeMap<Platform, BTreeMap<BuildProfile, Expected<Out>>>,
559572
preset: ReportProcessingPreset,
573+
implementation_status_filter: ImplementationStatus,
560574
) where
561575
Out: Debug + Default + EnumSetType,
562576
{
577+
let implementation_status = meta_props
578+
.implementation_status
579+
.or(parent_implementation_status.cloned())
580+
.unwrap_or_default();
581+
let should_apply_changes =
582+
|key| implementation_status[key] == implementation_status_filter;
563583
let reconciled = {
564584
let reported = |(platform, build_profile)| {
565585
reported
@@ -585,7 +605,11 @@ fn run(cli: Cli) -> ExitCode {
585605

586606
ExpandedPropertyValue::from_query(|platform, build_profile| {
587607
let key = (platform, build_profile);
588-
resolve(meta_expected[key], reported(key))
608+
if should_apply_changes(key) {
609+
resolve(meta_expected[key], reported(key))
610+
} else {
611+
meta_expected[key]
612+
}
589613
})
590614
} else {
591615
ExpandedPropertyValue::from_query(|platform, build_profile| {
@@ -659,7 +683,13 @@ fn run(cli: Cli) -> ExitCode {
659683
}
660684
}
661685

662-
reconcile(&mut properties, test_reported, preset);
686+
reconcile(
687+
None,
688+
&mut properties,
689+
test_reported,
690+
preset,
691+
implementation_status,
692+
);
663693

664694
let mut subtests = BTreeMap::new();
665695
for (subtest_name, subtest) in subtest_entries {
@@ -675,7 +705,13 @@ fn run(cli: Cli) -> ExitCode {
675705
} = subtest;
676706

677707
let mut subtest_properties = subtest_properties.unwrap_or_default();
678-
reconcile(&mut subtest_properties, subtest_reported, preset);
708+
reconcile(
709+
properties.implementation_status.as_ref(),
710+
&mut subtest_properties,
711+
subtest_reported,
712+
preset,
713+
implementation_status,
714+
);
679715
for (_, expected) in
680716
subtest_properties.expected.as_mut().unwrap().iter_mut()
681717
{

moz-webgpu-cts/src/metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::{
44
hash::Hash,
55
};
66

7+
use clap::ValueEnum;
78
use enum_map::Enum;
89
use enumset::EnumSetType;
910
use format::lazy_format;
@@ -562,7 +563,7 @@ fn format_file_properties(props: &FileProps) -> impl Display + '_ {
562563
})
563564
}
564565

565-
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize)]
566+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, ValueEnum)]
566567
pub enum ImplementationStatus {
567568
/// Indicates that functionality governing test(s) is implemented or currently being
568569
/// implemented, and generally expected to conform to tests.

0 commit comments

Comments
 (0)