Skip to content

Commit 32a7633

Browse files
DO NOT MERGE: what I'm currently driving
2 parents 32cd96d + 5a4e169 commit 32a7633

File tree

2 files changed

+108
-29
lines changed

2 files changed

+108
-29
lines changed

moz-webgpu-cts/src/main.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ enum Subcommand {
123123
/// `implementation-status`es that changes should be applied to.
124124
#[clap(value_enum, long, default_value = "backlog")]
125125
implementation_status: Vec<ImplementationStatus>,
126+
/// Assumptions about report coverage that affect cases where tests are present in
127+
/// metadata, but not in reports.
128+
#[clap(flatten)]
129+
on_missing: Option<OnMissing>,
126130
/// What do when only `SKIP` outcomes are found for tests and subtests.
127131
#[clap(value_enum, long, default_value_t = OnSkipOnly::Reconcile)]
128132
on_skip_only: OnSkipOnly,
@@ -205,6 +209,32 @@ impl From<UpdateExpectedPreset> for process_reports::ReportProcessingPreset {
205209
}
206210
}
207211

212+
/// See [`Subcommand::UpdateExpected::on_missing`].
213+
#[derive(Clone, Debug, Parser)]
214+
pub(crate) struct OnMissing {
215+
#[clap(long = "on-missing-log-level")]
216+
log_level: Option<log::Level>,
217+
#[clap(long = "on-missing-delete-because")]
218+
delete_because: Option<String>,
219+
}
220+
221+
impl From<OnMissing> for process_reports::OnMissing {
222+
fn from(value: OnMissing) -> Self {
223+
let OnMissing {
224+
log_level,
225+
delete_because,
226+
} = value;
227+
228+
let delete_because = delete_because.map(|s| &*s.leak());
229+
230+
// OPT: big hack, oh goodness
231+
Self {
232+
log_level,
233+
delete_because,
234+
}
235+
}
236+
}
237+
208238
/// See [`Subcommand::UpdateExpected::on_skip_only`].
209239
#[derive(Clone, Copy, Debug, ValueEnum)]
210240
pub(crate) enum OnSkipOnly {
@@ -290,6 +320,10 @@ fn run(cli: Cli) -> ExitCode {
290320
exec_report_spec,
291321
process_reports::ReportProcessingPreset::MigrateTestStructure,
292322
&mut should_update_expected::NeverUpdateExpected,
323+
process_reports::OnMissing {
324+
log_level: Some(log::Level::Info),
325+
delete_because: None,
326+
},
293327
OnSkipOnly::Ignore.into(),
294328
) {
295329
Ok(()) => ExitCode::SUCCESS,
@@ -299,6 +333,7 @@ fn run(cli: Cli) -> ExitCode {
299333
exec_report_spec,
300334
preset,
301335
implementation_status,
336+
on_missing,
302337
on_skip_only,
303338
} => {
304339
assert!(
@@ -309,6 +344,20 @@ fn run(cli: Cli) -> ExitCode {
309344
)
310345
);
311346
let allowed_implementation_statuses = EnumSet::from_iter(implementation_status);
347+
348+
let on_missing = on_missing.map(Into::into).unwrap_or_else(|| match preset {
349+
UpdateExpectedPreset::Merge => process_reports::OnMissing {
350+
log_level: Some(log::Level::Warn),
351+
delete_because: None,
352+
},
353+
UpdateExpectedPreset::ResetAll | UpdateExpectedPreset::ResetContradictory => {
354+
process_reports::OnMissing {
355+
log_level: Some(log::Level::Warn),
356+
delete_because: Some("expecting full test coverage"),
357+
}
358+
}
359+
});
360+
312361
match process_reports(
313362
browser,
314363
&checkout,
@@ -317,6 +366,7 @@ fn run(cli: Cli) -> ExitCode {
317366
&mut should_update_expected::ImplementationStatusFilter {
318367
allowed: allowed_implementation_statuses,
319368
},
369+
on_missing,
320370
on_skip_only.into(),
321371
) {
322372
Ok(()) => ExitCode::SUCCESS,
@@ -1372,6 +1422,7 @@ fn process_reports(
13721422
exec_report_spec: ExecReportSpec,
13731423
preset: process_reports::ReportProcessingPreset,
13741424
should_update_expected: &mut dyn ShouldUpdateExpected,
1425+
on_missing: process_reports::OnMissing,
13751426
on_skip_only: process_reports::OnSkipOnly,
13761427
) -> Result<(), AlreadyReportedToCommandline> {
13771428
let exec_report_paths = exec_report_spec.paths()?;
@@ -1386,6 +1437,7 @@ fn process_reports(
13861437
preset,
13871438
should_update_expected,
13881439
meta_files_by_path,
1440+
on_missing,
13891441
on_skip_only,
13901442
})?;
13911443

moz-webgpu-cts/src/process_reports.rs

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
use camino::Utf8PathBuf;
1212
use enumset::EnumSetType;
1313
use indexmap::IndexMap;
14-
use lazy_format::lazy_format;
14+
use lazy_format::make_lazy_format;
1515
use miette::{IntoDiagnostic, Report, WrapErr};
1616
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
1717
use whippit::metadata::SectionHeader;
@@ -57,6 +57,7 @@ pub(crate) struct ProcessReportsArgs<'a> {
5757
pub preset: ReportProcessingPreset,
5858
pub should_update_expected: &'a mut dyn should_update_expected::ShouldUpdateExpected,
5959
pub meta_files_by_path: IndexMap<Arc<PathBuf>, File>,
60+
pub on_missing: OnMissing,
6061
pub on_skip_only: OnSkipOnly,
6162
}
6263

@@ -68,6 +69,40 @@ pub(crate) enum ReportProcessingPreset {
6869
MigrateTestStructure,
6970
}
7071

72+
#[derive(Clone, Copy, Debug)]
73+
pub(crate) struct OnMissing {
74+
pub log_level: Option<log::Level>,
75+
pub delete_because: Option<&'static str>,
76+
}
77+
78+
impl OnMissing {
79+
fn should_delete<F>(&self, msg: F) -> bool
80+
where
81+
F: Fn(&mut std::fmt::Formatter<'_>) -> std::fmt::Result,
82+
{
83+
let &Self {
84+
log_level,
85+
delete_because,
86+
} = self;
87+
88+
if let Some(level) = log_level {
89+
log::log!(
90+
level,
91+
"{}",
92+
make_lazy_format!(|f| {
93+
if let Some(reason) = delete_because {
94+
write!(f, "removing metadata after {reason}, and ")?;
95+
}
96+
97+
msg(f)
98+
})
99+
);
100+
}
101+
102+
delete_because.is_some()
103+
}
104+
}
105+
71106
#[derive(Clone, Copy, Debug)]
72107
pub(crate) enum OnSkipOnly {
73108
/// Do not change metadata.
@@ -170,6 +205,7 @@ pub(crate) fn process_reports(
170205
preset,
171206
should_update_expected,
172207
meta_files_by_path,
208+
on_missing,
173209
on_skip_only,
174210
} = args;
175211

@@ -462,18 +498,14 @@ pub(crate) fn process_reports(
462498

463499
if test_reported.is_empty() {
464500
let test_entry_path = &test_entry_path;
465-
let msg = lazy_format!("no entries found in reports for {:?}", test_entry_path);
466-
match preset {
467-
ReportProcessingPreset::MergeOutcomes => log::warn!("{msg}"),
468-
ReportProcessingPreset::ResetAllOutcomes
469-
| ReportProcessingPreset::ResetContradictoryOutcomes => {
470-
log::warn!("removing metadata after {msg}");
471-
return None;
472-
}
473-
ReportProcessingPreset::MigrateTestStructure => {
474-
log::info!("removing metadata after {msg}");
475-
return None;
476-
}
501+
if on_missing.should_delete(|f| {
502+
write!(
503+
f,
504+
"no entries were found in reports for {:?}",
505+
test_entry_path
506+
)
507+
}) {
508+
return None;
477509
}
478510
}
479511

@@ -543,22 +575,17 @@ pub(crate) fn process_reports(
543575
if subtest_reported.is_empty() {
544576
let test_entry_path = &test_entry_path;
545577
let subtest_name = &subtest_name;
546-
let msg = lazy_format!(
547-
"no subtest entries found in reports for {:?}, subtest {:?}",
548-
test_entry_path,
549-
subtest_name,
550-
);
551-
match preset {
552-
ReportProcessingPreset::MergeOutcomes => log::warn!("{msg}"),
553-
ReportProcessingPreset::ResetAllOutcomes
554-
| ReportProcessingPreset::ResetContradictoryOutcomes => {
555-
log::warn!("removing metadata after {msg}");
556-
return None;
557-
}
558-
ReportProcessingPreset::MigrateTestStructure => {
559-
log::info!("removing metadata after {msg}");
560-
return None;
561-
}
578+
if on_missing.should_delete(|f| {
579+
write!(
580+
f,
581+
concat!(
582+
"no subtest entries found in reports ",
583+
"for {:?}, subtest {:?}"
584+
),
585+
test_entry_path, subtest_name,
586+
)
587+
}) {
588+
return None;
562589
}
563590
}
564591

0 commit comments

Comments
 (0)