Skip to content

Commit

Permalink
feat(update_expected): accept multiple implementation_statuses as a…
Browse files Browse the repository at this point in the history
… set
  • Loading branch information
ErichDonGubler committed Aug 1, 2024
1 parent c3cdd83 commit 6f90e36
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
38 changes: 23 additions & 15 deletions moz-webgpu-cts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use std::{
use crate::wpt::path::Browser;
use camino::Utf8PathBuf;
use clap::{Parser, ValueEnum};
use enumset::EnumSetType;
use enumset::{EnumSet, EnumSetType};
use format::lazy_format;
use indexmap::{IndexMap, IndexSet};
use itertools::Itertools;
Expand Down Expand Up @@ -85,9 +85,10 @@ enum Subcommand {
/// The heuristic for resolving differences between current metadata and processed reports.
#[clap(value_enum, long, default_value_t = UpdateExpectedPreset::ResetContradictory)]
preset: UpdateExpectedPreset,
/// The `implementation-status` that changes should be applied to.
#[clap(value_enum, long, default_value_t = ImplementationStatus::Backlog)]
implementation_status: ImplementationStatus,
/// `implementation-status`es that changes should be applied to. If not specified, defaults
/// to `implementing`.
#[clap(value_enum, long)]
implementation_status: Vec<ImplementationStatus>,
},
/// Parse test metadata, apply automated fixups, and re-emit it in normalized form.
#[clap(name = "fixup", alias = "fmt")]
Expand Down Expand Up @@ -292,16 +293,23 @@ fn run(cli: Cli) -> ExitCode {
exec_report_spec,
preset,
implementation_status,
} => match process_reports(
browser,
&checkout,
exec_report_spec,
preset.into(),
implementation_status,
) {
Ok(()) => ExitCode::SUCCESS,
Err(AlreadyReportedToCommandline) => ExitCode::FAILURE,
},
} => {
let implementation_status = if implementation_status.is_empty() {
ImplementationStatus::default().into()
} else {
EnumSet::from_iter(implementation_status)
};
match process_reports(
browser,
&checkout,
exec_report_spec,
preset.into(),
implementation_status,
) {
Ok(()) => ExitCode::SUCCESS,
Err(AlreadyReportedToCommandline) => ExitCode::FAILURE,
}
}
Subcommand::Fixup => {
log::info!("fixing up metadata in-place…");
let err_found = read_and_parse_all_metadata(browser, &checkout)
Expand Down Expand Up @@ -1304,7 +1312,7 @@ fn process_reports(
checkout: &Path,
exec_report_spec: ExecReportSpec,
preset: process_reports::ReportProcessingPreset,
implementation_status: ImplementationStatus,
implementation_status: EnumSet<ImplementationStatus>,
) -> Result<(), AlreadyReportedToCommandline> {
let exec_report_paths = exec_report_spec.paths()?;

Expand Down
9 changes: 5 additions & 4 deletions moz-webgpu-cts/src/process_reports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
};

use camino::Utf8PathBuf;
use enumset::EnumSetType;
use enumset::{EnumSet, EnumSetType};
use format::lazy_format;
use indexmap::IndexMap;
use miette::{IntoDiagnostic, Report, WrapErr};
Expand Down Expand Up @@ -53,7 +53,7 @@ pub(crate) struct ProcessReportsArgs<'a> {
pub checkout: &'a Path,
pub exec_report_paths: Vec<PathBuf>,
pub preset: ReportProcessingPreset,
pub implementation_status: ImplementationStatus,
pub implementation_status: EnumSet<ImplementationStatus>,
pub meta_files_by_path: IndexMap<Arc<PathBuf>, File>,
}

Expand Down Expand Up @@ -110,15 +110,16 @@ fn reconcile<Out>(
meta_props: &mut TestProps<Out>,
reported: BTreeMap<Platform, BTreeMap<BuildProfile, Expected<Out>>>,
preset: ReportProcessingPreset,
implementation_status_filter: ImplementationStatus,
implementation_status_filter: EnumSet<ImplementationStatus>,
) where
Out: Debug + Default + EnumSetType,
{
let implementation_status = meta_props
.implementation_status
.or(parent_implementation_status.cloned())
.unwrap_or_default();
let should_apply_changes = |key| implementation_status[key] == implementation_status_filter;
let should_apply_changes =
|key| implementation_status_filter.contains(implementation_status[key]);
let reconciled = {
let reported = |(platform, build_profile)| {
reported
Expand Down
2 changes: 1 addition & 1 deletion moz-webgpu-cts/src/wpt/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ fn format_file_properties(props: &FileProps) -> impl Display + '_ {
})
}

#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, ValueEnum)]
#[derive(Debug, Default, EnumSetType, Serialize, ValueEnum)]
pub enum ImplementationStatus {
/// Indicates that functionality governing test(s) is implemented or currently being
/// implemented, and generally expected to conform to tests.
Expand Down

0 comments on commit 6f90e36

Please sign in to comment.