Skip to content

Commit

Permalink
feat: add migrate subcmd.
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Aug 1, 2024
1 parent 84f266a commit cf9c46f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
37 changes: 37 additions & 0 deletions moz-webgpu-cts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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::<ImplementationStatus>::all(),
) {
Ok(()) => ExitCode::SUCCESS,
Err(AlreadyReportedToCommandline) => ExitCode::FAILURE,
},
Subcommand::UpdateExpected {
exec_report_spec,
preset,
Expand Down
11 changes: 11 additions & 0 deletions moz-webgpu-cts/src/process_reports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub(crate) enum ReportProcessingPreset {
ResetContradictoryOutcomes,
MergeOutcomes,
ResetAllOutcomes,
MigrateTestStructure,
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -137,6 +138,7 @@ fn reconcile<Out>(
Some(rep) => meta | rep,
None => meta,
},
ReportProcessingPreset::MigrateTestStructure => |meta, _rep| meta,
};

ExpandedPropertyValue::from_query(|platform, build_profile| {
Expand All @@ -156,6 +158,7 @@ fn reconcile<Out>(
reported((platform, build_profile)).unwrap_or_default()
})
}
ReportProcessingPreset::MigrateTestStructure => Default::default(),
}
}
};
Expand Down Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit cf9c46f

Please sign in to comment.