Skip to content

Commit f3af30c

Browse files
fix(process_reports)!: preserve _all_ test and subtest metadata
1 parent 184132f commit f3af30c

2 files changed

Lines changed: 24 additions & 90 deletions

File tree

moz-webgpu-cts/src/main.rs

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use self::{
88
BuildProfile, File, FileProps, Platform, Subtest, SubtestOutcome, Test, TestOutcome,
99
TestProps,
1010
},
11-
process_reports::{Entry, MaybeDisabled, TestEntry},
11+
process_reports::{Entry, TestEntry},
1212
report::{
1313
ExecutionReport, RunInfo, SubtestExecutionResult, TestExecutionEntry, TestExecutionResult,
1414
},
@@ -340,11 +340,7 @@ fn run(cli: Cli) -> ExitCode {
340340

341341
for (SectionHeader(name), test) in tests {
342342
let Test {
343-
properties:
344-
TestProps {
345-
is_disabled,
346-
expectations,
347-
},
343+
properties,
348344
subtests,
349345
} = test;
350346

@@ -364,12 +360,7 @@ fn run(cli: Cli) -> ExitCode {
364360
let test_path = &test_path;
365361
let mut reported_dupe_already = false;
366362

367-
let maybe_disabled = if is_disabled {
368-
MaybeDisabled::Disabled
369-
} else {
370-
MaybeDisabled::Enabled(expectations)
371-
};
372-
if let Some(_old) = test_entry.metadata.replace(maybe_disabled) {
363+
if let Some(_old) = test_entry.meta_props.replace(properties) {
373364
freak_out_do_nothing(
374365
&lazy_format!(
375366
"duplicate entry for {test_path:?}, discarding previous entries with this and further dupes"
@@ -379,21 +370,10 @@ fn run(cli: Cli) -> ExitCode {
379370
}
380371

381372
for (SectionHeader(subtest_name), subtest) in subtests {
382-
let Subtest {
383-
properties:
384-
TestProps {
385-
is_disabled,
386-
expectations,
387-
},
388-
} = subtest;
373+
let Subtest { properties } = subtest;
389374
let subtest_entry =
390375
subtest_entries.entry(subtest_name.clone()).or_default();
391-
let maybe_disabled = if is_disabled {
392-
MaybeDisabled::Disabled
393-
} else {
394-
MaybeDisabled::Enabled(expectations)
395-
};
396-
if let Some(_old) = subtest_entry.metadata.replace(maybe_disabled) {
376+
if let Some(_old) = subtest_entry.meta_props.replace(properties) {
397377
if !reported_dupe_already {
398378
freak_out_do_nothing(&lazy_format!(
399379
"duplicate subtest in {test_path:?} named {subtest_name:?}, discarding previous entries with this and further dupes"
@@ -533,19 +513,18 @@ fn run(cli: Cli) -> ExitCode {
533513
where
534514
Out: Debug + Default + EnumSetType,
535515
{
536-
let Entry { metadata, reported } = entry;
537-
538-
let metadata = metadata
539-
.map(|maybe_disabled| {
540-
maybe_disabled.map_enabled(|opt| opt.unwrap_or_default())
541-
})
542-
.unwrap_or_default();
543-
516+
let Entry {
517+
meta_props,
518+
reported,
519+
} = entry;
544520
let normalize = NormalizedExpectationPropertyValue::from_fully_expanded;
545521

546-
let reconciled_expectations = metadata.map_enabled(|metadata| {
522+
let mut meta_props = meta_props.unwrap_or_default();
523+
meta_props.expectations = Some('resolve: {
547524
let resolve = match preset {
548-
ReportProcessingPreset::ResetAll => return normalize(reported),
525+
ReportProcessingPreset::ResetAll => {
526+
break 'resolve normalize(reported);
527+
}
549528
ReportProcessingPreset::ResetContradictory => {
550529
|meta: Expectation<_>, rep: Option<Expectation<_>>| {
551530
rep.filter(|rep| !meta.is_superset(rep)).unwrap_or(meta)
@@ -565,7 +544,11 @@ fn run(cli: Cli) -> ExitCode {
565544
(
566545
build_profile,
567546
resolve(
568-
metadata.get(platform, build_profile),
547+
meta_props
548+
.expectations
549+
.as_ref()
550+
.unwrap_or(&Default::default())
551+
.get(platform, build_profile),
569552
reported
570553
.get(&platform)
571554
.and_then(|rep| {
@@ -581,17 +564,7 @@ fn run(cli: Cli) -> ExitCode {
581564
.collect(),
582565
)
583566
});
584-
585-
match reconciled_expectations {
586-
MaybeDisabled::Disabled => TestProps {
587-
is_disabled: true,
588-
expectations: Default::default(),
589-
},
590-
MaybeDisabled::Enabled(expectations) => TestProps {
591-
is_disabled: false,
592-
expectations: Some(expectations),
593-
},
594-
}
567+
meta_props
595568
}
596569

597570
let TestEntry {

moz-webgpu-cts/src/process_reports.rs

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,19 @@ use std::collections::BTreeMap;
33
use enumset::EnumSetType;
44

55
use crate::{
6-
metadata::{BuildProfile, Platform, SubtestOutcome, TestOutcome},
7-
shared::{Expectation, NormalizedExpectationPropertyValue},
6+
metadata::{BuildProfile, Platform, SubtestOutcome, TestOutcome, TestProps},
7+
shared::Expectation,
88
};
99

10-
#[derive(Debug)]
10+
#[derive(Debug, Default)]
1111
pub(crate) struct Entry<Out>
1212
where
1313
Out: EnumSetType,
1414
{
15-
pub metadata: Option<MaybeDisabled<Option<NormalizedExpectationPropertyValue<Out>>>>,
15+
pub meta_props: Option<TestProps<Out>>,
1616
pub reported: BTreeMap<Platform, BTreeMap<BuildProfile, Expectation<Out>>>,
1717
}
1818

19-
impl<Out> Default for Entry<Out>
20-
where
21-
Out: EnumSetType,
22-
{
23-
fn default() -> Self {
24-
Self {
25-
metadata: None,
26-
reported: Default::default(),
27-
}
28-
}
29-
}
30-
31-
#[derive(Debug)]
32-
pub(crate) enum MaybeDisabled<T> {
33-
Disabled,
34-
Enabled(T),
35-
}
36-
37-
impl<T> Default for MaybeDisabled<T>
38-
where
39-
T: Default,
40-
{
41-
fn default() -> Self {
42-
Self::Enabled(Default::default())
43-
}
44-
}
45-
46-
impl<T> MaybeDisabled<T> {
47-
pub fn map_enabled<U, F>(self, f: F) -> MaybeDisabled<U>
48-
where
49-
F: FnOnce(T) -> U,
50-
{
51-
match self {
52-
Self::Disabled => MaybeDisabled::Disabled,
53-
Self::Enabled(t) => MaybeDisabled::Enabled(f(t)),
54-
}
55-
}
56-
}
57-
5819
#[derive(Debug, Default)]
5920
pub(crate) struct TestEntry {
6021
pub entry: Entry<TestOutcome>,

0 commit comments

Comments
 (0)