-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(update_expected): hoist logic for
expected
filtering to ca…
…llers of `process_reports`
- Loading branch information
1 parent
fd20195
commit f9db3c8
Showing
3 changed files
with
96 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
moz-webgpu-cts/src/process_reports/should_update_expected.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use std::fmt::Debug; | ||
|
||
use enumset::EnumSet; | ||
|
||
use crate::wpt::metadata::{ | ||
properties::{Expected, NonNormalizedPropertyValue}, | ||
BuildProfile, ImplementationStatus, Platform, SubtestOutcome, TestOutcome, TestProps, | ||
}; | ||
|
||
pub(crate) trait ShouldUpdateExpected: Debug { | ||
fn test( | ||
&mut self, | ||
meta_props: &TestProps<TestOutcome>, | ||
reported: &NonNormalizedPropertyValue<Expected<TestOutcome>>, | ||
key: (Platform, BuildProfile), | ||
) -> bool; | ||
fn subtest( | ||
&mut self, | ||
meta_props: &TestProps<SubtestOutcome>, | ||
reported: &NonNormalizedPropertyValue<Expected<SubtestOutcome>>, | ||
parent_meta_props: &TestProps<TestOutcome>, | ||
key: (Platform, BuildProfile), | ||
) -> bool; | ||
} | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct ImplementationStatusFilter { | ||
pub allowed: EnumSet<ImplementationStatus>, | ||
} | ||
|
||
impl ImplementationStatusFilter { | ||
fn is_allowed(&self, implementation_status: ImplementationStatus) -> bool { | ||
let Self { allowed } = self; | ||
allowed.contains(implementation_status) | ||
} | ||
} | ||
|
||
impl ShouldUpdateExpected for ImplementationStatusFilter { | ||
fn test( | ||
&mut self, | ||
meta_props: &TestProps<TestOutcome>, | ||
_reported: &NonNormalizedPropertyValue<Expected<TestOutcome>>, | ||
key: (Platform, BuildProfile), | ||
) -> bool { | ||
let status = meta_props.implementation_status.unwrap_or_default()[key]; | ||
self.is_allowed(status) | ||
} | ||
|
||
fn subtest( | ||
&mut self, | ||
meta_props: &TestProps<SubtestOutcome>, | ||
_reported: &NonNormalizedPropertyValue<Expected<SubtestOutcome>>, | ||
parent_meta_props: &TestProps<TestOutcome>, | ||
key: (Platform, BuildProfile), | ||
) -> bool { | ||
let status = meta_props | ||
.implementation_status | ||
.or(parent_meta_props.implementation_status) | ||
.unwrap_or_default()[key]; | ||
self.is_allowed(status) | ||
} | ||
} |