From cf9c46f71f0c4d02a905f154b4c65daefbc1b2c7 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 30 Jul 2024 13:41:24 -0400 Subject: [PATCH] feat: add `migrate` subcmd. --- moz-webgpu-cts/src/main.rs | 37 +++++++++++++++++++++++++++ moz-webgpu-cts/src/process_reports.rs | 11 ++++++++ 2 files changed, 48 insertions(+) diff --git a/moz-webgpu-cts/src/main.rs b/moz-webgpu-cts/src/main.rs index a2f5fed..9dd8a9c 100644 --- a/moz-webgpu-cts/src/main.rs +++ b/moz-webgpu-cts/src/main.rs @@ -59,6 +59,33 @@ struct Cli { #[derive(Debug, Parser)] enum Subcommand { + /// Migrate old test structure in metadata to that found in `wptreport.json` reports. + /// + /// When a new version of CTS is run by your implementation of WebGPU, new execution reports + /// may differ from old ones in various ways: + /// + /// 1. Test may have been added, deleted, or moved. + /// + /// It requires human judgment to determine what additions and deletions are actually + /// movements of the same test coverage. + /// 2. Tests' actual outcomes on your implementation may change, since implementations of + /// existing tests may have changed. + /// + /// This command implements (only) the changes from (1) in your metadata by using the reports + /// you provide to: + /// + /// 1. Remove _all_ metadata from test paths that are currently in metadata, but not observedn + /// execution reports. + /// 2. Add empty metadata entries for test paths that are observed in execution reports, but + /// absent from current metadata. + /// + /// The diff produced by the above changes makes it easier to determine what tests may have + /// moved, and, by extension, whether you should attempt to migrate metadata for subsequent + /// test runs. + Migrate { + #[clap(flatten)] + exec_report_spec: ExecReportSpec, + }, /// Adjust expected test outcomes in metadata, optionally using `wptreport.json` reports from /// CI runs covering your browser's implementation of WebGPU. /// @@ -289,6 +316,16 @@ fn run(cli: Cli) -> ExitCode { }; match subcommand { + Subcommand::Migrate { exec_report_spec } => match process_reports( + browser, + &checkout, + exec_report_spec, + process_reports::ReportProcessingPreset::MigrateTestStructure, + EnumSet::::all(), + ) { + Ok(()) => ExitCode::SUCCESS, + Err(AlreadyReportedToCommandline) => ExitCode::FAILURE, + }, Subcommand::UpdateExpected { exec_report_spec, preset, diff --git a/moz-webgpu-cts/src/process_reports.rs b/moz-webgpu-cts/src/process_reports.rs index 5e206ae..8a2512f 100644 --- a/moz-webgpu-cts/src/process_reports.rs +++ b/moz-webgpu-cts/src/process_reports.rs @@ -63,6 +63,7 @@ pub(crate) enum ReportProcessingPreset { ResetContradictoryOutcomes, MergeOutcomes, ResetAllOutcomes, + MigrateTestStructure, } #[derive(Debug, Default)] @@ -137,6 +138,7 @@ fn reconcile( Some(rep) => meta | rep, None => meta, }, + ReportProcessingPreset::MigrateTestStructure => |meta, _rep| meta, }; ExpandedPropertyValue::from_query(|platform, build_profile| { @@ -156,6 +158,7 @@ fn reconcile( reported((platform, build_profile)).unwrap_or_default() }) } + ReportProcessingPreset::MigrateTestStructure => Default::default(), } } }; @@ -459,6 +462,10 @@ pub(crate) fn process_reports( log::warn!("removing metadata after {msg}"); return None; } + ReportProcessingPreset::MigrateTestStructure => { + log::info!("removing metadata after {msg}"); + return None; + } } } @@ -532,6 +539,10 @@ pub(crate) fn process_reports( log::warn!("removing metadata after {msg}"); return None; } + ReportProcessingPreset::MigrateTestStructure => { + log::info!("removing metadata after {msg}"); + return None; + } } }