Skip to content

Commit 07725df

Browse files
Merge pull request #153 from erichdongubler-mozilla/update_backlog-verb_criteria-model
2 parents 6f79c14 + c1cb735 commit 07725df

2 files changed

Lines changed: 79 additions & 18 deletions

File tree

moz-webgpu-cts/src/main.rs

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@ enum Subcommand {
127127
#[clap(value_enum, long, default_value_t = Default::default())]
128128
on_zero_item: OnZeroItem,
129129
},
130-
/// Identify and promote tests that are ready to come out of the `backlog` implementation
131-
/// status.
130+
/// Set `implementation-status` properties to `backlog` or `implementing` based on a
131+
/// given `criteria`, allowing changes only in the permitted `direction`.
132132
UpdateBacklog {
133-
/// The mode to use for updating tests.
133+
/// Direction(s) permitted for `implementation-status` changes.
134+
direction: UpdateBacklogDirection,
135+
/// The criteria to use to determine whether something is ready to come out of `backlog`.
134136
#[clap(subcommand)]
135-
preset: UpdateBacklogSubcommand,
137+
criteria: UpdateBacklogCriteria,
136138
},
137139
/// Dump all metadata as JSON. Do so at your own risk; no guarantees are made about the
138140
/// schema of this JSON, for now.
@@ -289,10 +291,34 @@ enum OnZeroItem {
289291
Hide,
290292
}
291293

294+
#[derive(Clone, Copy, Debug, ValueEnum)]
295+
enum UpdateBacklogDirection {
296+
/// Allows promotions from `backlog` to `implementing`.
297+
Promote,
298+
Demote,
299+
Sync,
300+
}
301+
302+
impl UpdateBacklogDirection {
303+
pub fn can_promote(self) -> bool {
304+
match self {
305+
Self::Promote | Self::Sync => true,
306+
Self::Demote => false,
307+
}
308+
}
309+
310+
pub fn can_demote(self) -> bool {
311+
match self {
312+
Self::Demote | Self::Sync => true,
313+
Self::Promote => false,
314+
}
315+
}
316+
}
317+
292318
#[derive(Clone, Copy, Debug, Parser)]
293-
enum UpdateBacklogSubcommand {
294-
/// Remove tests that expect only `PASS` outcomes on all platforms from `backlog`.
295-
PromotePermaPassing {
319+
enum UpdateBacklogCriteria {
320+
/// Determine status based on `PASS` outcomes on all platforms from `backlog`.
321+
PermaPassing {
296322
#[clap(long)]
297323
only_across_all_platforms: bool,
298324
},
@@ -985,7 +1011,10 @@ fn run(cli: Cli) -> ExitCode {
9851011
println!("Full analysis: {analysis:#?}");
9861012
ExitCode::SUCCESS
9871013
}
988-
Subcommand::UpdateBacklog { preset } => {
1014+
Subcommand::UpdateBacklog {
1015+
direction,
1016+
criteria,
1017+
} => {
9891018
let mut files = {
9901019
let mut found_parse_err = false;
9911020
let extracted = read_and_parse_all_metadata(browser, &checkout)
@@ -1063,18 +1092,40 @@ fn run(cli: Cli) -> ExitCode {
10631092
// subtests afterwards.
10641093
let value_across_all_platforms =
10651094
|| cases.into_iter().map(|(_, case)| case).all_equal_value();
1066-
match preset {
1067-
UpdateBacklogSubcommand::PromotePermaPassing {
1095+
fn apply_criteria(
1096+
direction: UpdateBacklogDirection,
1097+
case: Case,
1098+
) -> Option<ImplementationStatus> {
1099+
match case {
1100+
Case::PermaPass if direction.can_promote() => {
1101+
Some(ImplementationStatus::Implementing)
1102+
}
1103+
Case::Other if direction.can_demote() => {
1104+
Some(ImplementationStatus::Backlog)
1105+
}
1106+
_ => None,
1107+
}
1108+
}
1109+
match criteria {
1110+
UpdateBacklogCriteria::PermaPassing {
10681111
only_across_all_platforms,
10691112
} => {
1070-
if matches!(value_across_all_platforms(), Ok(Case::PermaPass)) {
1071-
properties.implementation_status = None;
1072-
} else if !only_across_all_platforms {
1073-
properties.implementation_status =
1074-
Some(cases.map(|case| match case {
1075-
Case::PermaPass => ImplementationStatus::Implementing,
1076-
Case::Other => ImplementationStatus::Backlog,
1077-
}));
1113+
if only_across_all_platforms {
1114+
properties.implementation_status = apply_criteria(
1115+
direction,
1116+
value_across_all_platforms().unwrap_or(Case::Other),
1117+
)
1118+
.map(ExpandedPropertyValue::unconditional)
1119+
.or(properties.implementation_status);
1120+
} else {
1121+
let old_impl_status =
1122+
properties.implementation_status.unwrap_or_default();
1123+
properties.implementation_status.replace(cases.map_with(
1124+
|key, case| {
1125+
apply_criteria(direction, case)
1126+
.unwrap_or_else(|| old_impl_status[key])
1127+
},
1128+
));
10781129
}
10791130
}
10801131
}

moz-webgpu-cts/src/wpt/metadata/properties.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ impl<T> ExpandedPropertyValue<T> {
276276
)
277277
}
278278

279+
pub(crate) fn map_with<U, F>(self, f: F) -> ExpandedPropertyValue<U>
280+
where
281+
F: FnMut((Platform, BuildProfile), T) -> U,
282+
{
283+
let mut f = f;
284+
ExpandedPropertyValue(self.into_inner().map(|platform, by_build_profile| {
285+
by_build_profile.map(|build_profile, t| f((platform, build_profile), t))
286+
}))
287+
}
288+
279289
fn into_inner(self) -> ExpandedPropertyValueData<T> {
280290
let Self(inner) = self;
281291
inner

0 commit comments

Comments
 (0)