Skip to content

Commit

Permalink
WIP: feat(update_backlog): change CLI to permit demotion and demote-p…
Browse files Browse the repository at this point in the history
…romote
  • Loading branch information
ErichDonGubler committed Aug 8, 2024
1 parent 8196171 commit f8424c2
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 16 deletions.
81 changes: 65 additions & 16 deletions moz-webgpu-cts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ enum Subcommand {
/// Identify and promote tests that are ready to come out of the `backlog` implementation
/// status.
UpdateBacklog {
direction: UpdateBacklogDirection,
/// The mode to use for updating tests.
#[clap(subcommand)]
preset: UpdateBacklogSubcommand,
criteria: UpdateBacklogCriteria,
},
/// Dump all metadata as JSON. Do so at your own risk; no guarantees are made about the
/// schema of this JSON, for now.
Expand Down Expand Up @@ -289,11 +290,34 @@ enum OnZeroItem {
Hide,
}

#[derive(Clone, Copy, Debug, ValueEnum)]
enum UpdateBacklogDirection {
Promote,
Demote,
Sync,
}

impl UpdateBacklogDirection {
pub fn can_promote(self) -> bool {
match self {
Self::Promote | Self::Sync => true,
Self::Demote => false,
}
}

pub fn can_demote(self) -> bool {
match self {
Self::Demote | Self::Sync => true,
Self::Promote => false,
}
}
}

#[derive(Clone, Copy, Debug, Parser)]
enum UpdateBacklogSubcommand {
/// Remove tests that expect only `PASS` outcomes on all platforms from `backlog`.
PromotePermaPassing {
#[clap(long, default_value_t = true)]
enum UpdateBacklogCriteria {
/// Determine status based on `PASS` outcomes on all platforms from `backlog`.
PermaPassing {
#[clap(long)]
only_across_all_platforms: bool,
},
}
Expand Down Expand Up @@ -976,7 +1000,10 @@ fn run(cli: Cli) -> ExitCode {
println!("Full analysis: {analysis:#?}");
ExitCode::SUCCESS
}
Subcommand::UpdateBacklog { preset } => {
Subcommand::UpdateBacklog {
direction,
criteria,
} => {
let mut files = {
let mut found_parse_err = false;
let extracted = read_and_parse_all_metadata(browser, &checkout)
Expand Down Expand Up @@ -1054,18 +1081,40 @@ fn run(cli: Cli) -> ExitCode {
// subtests afterwards.
let value_across_all_platforms =
|| cases.into_iter().map(|(_, case)| case).all_equal_value();
match preset {
UpdateBacklogSubcommand::PromotePermaPassing {
fn apply_criteria(
direction: UpdateBacklogDirection,
case: Case,
) -> Option<ImplementationStatus> {
match case {
Case::PermaPass if direction.can_promote() => {
Some(ImplementationStatus::Implementing)
}
Case::Other if direction.can_demote() => {
Some(ImplementationStatus::Backlog)
}
_ => None,
}
}
match criteria {
UpdateBacklogCriteria::PermaPassing {
only_across_all_platforms,
} => {
if matches!(value_across_all_platforms(), Ok(Case::PermaPass)) {
properties.implementation_status = None;
} else if !only_across_all_platforms {
properties.implementation_status =
Some(cases.map(|case| match case {
Case::PermaPass => ImplementationStatus::Implementing,
Case::Other => ImplementationStatus::Backlog,
}));
if only_across_all_platforms {
properties.implementation_status = apply_criteria(
direction,
value_across_all_platforms().unwrap_or(Case::Other),
)
.map(ExpandedPropertyValue::unconditional)
.or(properties.implementation_status);
} else {
let old_impl_status =
properties.implementation_status.unwrap_or_default();
properties.implementation_status.replace(cases.map_with(
|key, case| {
apply_criteria(direction, case)
.unwrap_or_else(|| old_impl_status[key])
},
));
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions moz-webgpu-cts/src/wpt/metadata/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,16 @@ impl<T> ExpandedPropertyValue<T> {
)
}

pub(crate) fn map_with<U, F>(self, f: F) -> ExpandedPropertyValue<U>
where
F: FnMut((Platform, BuildProfile), T) -> U,
{
let mut f = f;
ExpandedPropertyValue(self.into_inner().map(|platform, by_build_profile| {
by_build_profile.map(|build_profile, t| f((platform, build_profile), t))
}))
}

fn into_inner(self) -> ExpandedPropertyValueData<T> {
let Self(inner) = self;
inner
Expand Down

0 comments on commit f8424c2

Please sign in to comment.