Skip to content

Commit 57a883f

Browse files
feat: add migrate subcmd.
1 parent 29a9c50 commit 57a883f

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

moz-webgpu-cts/src/main.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,33 @@ struct Cli {
6262

6363
#[derive(Debug, Parser)]
6464
enum Subcommand {
65+
/// Migrate old test structure in metadata to that found in `wptreport.json` reports.
66+
///
67+
/// When a new version of CTS is run by your implementation of WebGPU, new execution reports
68+
/// may differ from old ones in various ways:
69+
///
70+
/// 1. Test may have been added, deleted, or moved.
71+
///
72+
/// It requires human judgment to determine what additions and deletions are actually
73+
/// movements of the same test coverage.
74+
/// 2. Tests' actual outcomes on your implementation may change, since implementations of
75+
/// existing tests may have changed.
76+
///
77+
/// This command implements (only) the changes from (1) in your metadata by using the reports
78+
/// you provide to:
79+
///
80+
/// 1. Remove _all_ metadata from test paths that are currently in metadata, but not observedn
81+
/// execution reports.
82+
/// 2. Add empty metadata entries for test paths that are observed in execution reports, but
83+
/// absent from current metadata.
84+
///
85+
/// The diff produced by the above changes makes it easier to determine what tests may have
86+
/// moved, and, by extension, whether you should attempt to migrate metadata for subsequent
87+
/// test runs.
88+
Migrate {
89+
#[clap(flatten)]
90+
exec_report_spec: ExecReportSpec,
91+
},
6592
/// Adjust expected test outcomes in metadata, optionally using `wptreport.json` reports from
6693
/// CI runs covering your browser's implementation of WebGPU.
6794
///
@@ -292,6 +319,16 @@ fn run(cli: Cli) -> ExitCode {
292319
};
293320

294321
match subcommand {
322+
Subcommand::Migrate { exec_report_spec } => match process_reports(
323+
browser,
324+
&checkout,
325+
exec_report_spec,
326+
process_reports::ReportProcessingPreset::MigrateTestStructure,
327+
&mut should_update_expected::NeverUpdateExpected,
328+
) {
329+
Ok(()) => ExitCode::SUCCESS,
330+
Err(AlreadyReportedToCommandline) => ExitCode::FAILURE,
331+
},
295332
Subcommand::UpdateExpected {
296333
exec_report_spec,
297334
preset,

moz-webgpu-cts/src/process_reports.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub(crate) enum ReportProcessingPreset {
6565
ResetContradictoryOutcomes,
6666
MergeOutcomes,
6767
ResetAllOutcomes,
68+
MigrateTestStructure,
6869
}
6970

7071
#[derive(Debug, Default)]
@@ -132,6 +133,7 @@ fn reconcile<Out>(
132133
Some(rep) => meta | rep,
133134
None => meta,
134135
},
136+
ReportProcessingPreset::MigrateTestStructure => |meta, _rep| meta,
135137
};
136138

137139
ExpandedPropertyValue::from_query(|platform, build_profile| {
@@ -447,6 +449,10 @@ pub(crate) fn process_reports(
447449
log::warn!("removing metadata after {msg}");
448450
return None;
449451
}
452+
ReportProcessingPreset::MigrateTestStructure => {
453+
log::info!("removing metadata after {msg}");
454+
return None;
455+
}
450456
}
451457
}
452458

@@ -521,6 +527,10 @@ pub(crate) fn process_reports(
521527
log::warn!("removing metadata after {msg}");
522528
return None;
523529
}
530+
ReportProcessingPreset::MigrateTestStructure => {
531+
log::info!("removing metadata after {msg}");
532+
return None;
533+
}
524534
}
525535
}
526536

moz-webgpu-cts/src/process_reports/should_update_expected.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,27 @@ impl ShouldUpdateExpected for ImplementationStatusFilter {
6060
self.is_allowed(status)
6161
}
6262
}
63+
64+
#[derive(Debug)]
65+
pub(crate) struct NeverUpdateExpected;
66+
67+
impl ShouldUpdateExpected for NeverUpdateExpected {
68+
fn test(
69+
&mut self,
70+
_meta_props: &TestProps<TestOutcome>,
71+
_reported: &NonNormalizedPropertyValue<Expected<TestOutcome>>,
72+
_key: (Platform, BuildProfile),
73+
) -> bool {
74+
false
75+
}
76+
77+
fn subtest(
78+
&mut self,
79+
_meta_props: &TestProps<SubtestOutcome>,
80+
_reported: &NonNormalizedPropertyValue<Expected<SubtestOutcome>>,
81+
_parent_meta_props: &TestProps<TestOutcome>,
82+
_key: (Platform, BuildProfile),
83+
) -> bool {
84+
false
85+
}
86+
}

0 commit comments

Comments
 (0)