Skip to content

Commit f0c69eb

Browse files
feat: tags property on tests and subtests
1 parent 5da8641 commit f0c69eb

3 files changed

Lines changed: 152 additions & 1 deletion

File tree

moz-webgpu-cts/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ fn run(cli: Cli) -> ExitCode {
579579
is_disabled,
580580
expected,
581581
implementation_status: _,
582+
tags: _,
582583
} = properties;
583584

584585
let test_name = Arc::new(test_name);
@@ -703,6 +704,7 @@ fn run(cli: Cli) -> ExitCode {
703704
is_disabled,
704705
expected,
705706
implementation_status: _,
707+
tags: _,
706708
} = properties;
707709

708710
if is_disabled {

moz-webgpu-cts/src/wpt/metadata.rs

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ where
785785
is_disabled,
786786
expected,
787787
implementation_status,
788+
tags,
788789
} = property;
789790

790791
if *is_disabled {
@@ -865,6 +866,25 @@ where
865866
Ok(())
866867
}
867868

869+
if let Some(tags) = tags {
870+
use std::borrow::Cow;
871+
872+
#[derive(Clone, Debug, Default, Eq, PartialEq)]
873+
struct TagsDisplay<'a>(Cow<'a, Vec<String>>);
874+
875+
impl Display for TagsDisplay<'_> {
876+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
877+
let Self(tags) = self;
878+
Display::fmt(&format_args!("[{}]", tags.iter().join_with(", ")), f)
879+
}
880+
}
881+
882+
let tags_ref = tags.as_ref();
883+
let tags_ref = tags_ref.map(Cow::Borrowed).map(TagsDisplay);
884+
885+
write_normalized(f, &indent, TAGS_IDENT, tags_ref)?;
886+
}
887+
868888
if let Some(implementation_status) = implementation_status {
869889
write_normalized(
870890
f,
@@ -903,6 +923,7 @@ where
903923
pub is_disabled: bool,
904924
pub expected: Option<ExpandedPropertyValue<Expected<Out>>>,
905925
pub implementation_status: Option<ExpandedPropertyValue<ImplementationStatus>>,
926+
pub tags: Option<ExpandedPropertyValue<Vec<String>>>,
906927
}
907928

908929
impl<'a, Out> TestProps<Out>
@@ -914,6 +935,7 @@ where
914935
is_disabled,
915936
expected,
916937
implementation_status,
938+
tags,
917939
} = self;
918940

919941
let TestProp { kind, span } = prop;
@@ -992,6 +1014,7 @@ where
9921014
implementation_status,
9931015
val,
9941016
),
1017+
TestPropKind::Tags(val) => conditional(emitter, span, TAGS_IDENT, tags, val),
9951018
}
9961019
}
9971020
}
@@ -1019,6 +1042,7 @@ where
10191042
Expected(PropertyValue<Applicability, Expected<Out>>),
10201043
Disabled,
10211044
ImplementationStatus(PropertyValue<Applicability, ImplementationStatus>),
1045+
Tags(PropertyValue<Applicability, Vec<String>>),
10221046
}
10231047

10241048
impl<Out> TestProp<Out>
@@ -1196,18 +1220,23 @@ where
11961220
helper
11971221
.parser(
11981222
ImplementationStatus::property_ident_parser(),
1199-
conditional_term,
1223+
conditional_term.clone(),
12001224
ImplementationStatus::property_value_parser(),
12011225
)
12021226
.map_with(|((), val), e| TestProp {
12031227
span: e.span(),
12041228
kind: TestPropKind::ImplementationStatus(val),
12051229
}),
1230+
tags_parser(helper, conditional_term).map_with(|val, e| TestProp {
1231+
span: e.span(),
1232+
kind: TestPropKind::Tags(val),
1233+
}),
12061234
))
12071235
}
12081236
}
12091237

12101238
pub(crate) const EXPECTED_IDENT: &str = "expected";
1239+
pub(crate) const TAGS_IDENT: &str = "tags";
12111240
pub(crate) const PASS: &str = "PASS";
12121241
pub(crate) const FAIL: &str = "FAIL";
12131242
pub(crate) const NOTRUN: &str = "NOTRUN";
@@ -1371,6 +1400,7 @@ r#"
13711400
is_disabled: false,
13721401
expected: None,
13731402
implementation_status: None,
1403+
tags: None,
13741404
},
13751405
subtests: {},
13761406
},
@@ -1405,13 +1435,15 @@ r#"
14051435
is_disabled: false,
14061436
expected: None,
14071437
implementation_status: None,
1438+
tags: None,
14081439
},
14091440
subtests: {
14101441
"blarg": Subtest {
14111442
properties: TestProps {
14121443
is_disabled: false,
14131444
expected: None,
14141445
implementation_status: None,
1446+
tags: None,
14151447
},
14161448
},
14171449
},
@@ -1448,6 +1480,7 @@ r#"
14481480
is_disabled: false,
14491481
expected: None,
14501482
implementation_status: None,
1483+
tags: None,
14511484
},
14521485
subtests: {
14531486
"blarg": Subtest {
@@ -1484,6 +1517,7 @@ r#"
14841517
),
14851518
),
14861519
implementation_status: None,
1520+
tags: None,
14871521
},
14881522
},
14891523
},
@@ -1516,6 +1550,7 @@ r#"
15161550
is_disabled: false,
15171551
expected: None,
15181552
implementation_status: None,
1553+
tags: None,
15191554
},
15201555
subtests: {
15211556
"blarg": Subtest {
@@ -1558,6 +1593,7 @@ r#"
15581593
),
15591594
),
15601595
implementation_status: None,
1596+
tags: None,
15611597
},
15621598
},
15631599
},
@@ -1617,6 +1653,7 @@ r#"
16171653
),
16181654
),
16191655
implementation_status: None,
1656+
tags: None,
16201657
},
16211658
subtests: {
16221659
"blarg": Subtest {
@@ -1653,6 +1690,7 @@ r#"
16531690
),
16541691
),
16551692
implementation_status: None,
1693+
tags: None,
16561694
},
16571695
},
16581696
},
@@ -1683,6 +1721,7 @@ r#"
16831721
is_disabled: false,
16841722
expected: None,
16851723
implementation_status: None,
1724+
tags: None,
16861725
},
16871726
subtests: {
16881727
"blarg": Subtest {
@@ -1719,6 +1758,7 @@ r#"
17191758
),
17201759
),
17211760
implementation_status: None,
1761+
tags: None,
17221762
},
17231763
},
17241764
},
@@ -1750,6 +1790,7 @@ r#"
17501790
is_disabled: false,
17511791
expected: None,
17521792
implementation_status: None,
1793+
tags: None,
17531794
},
17541795
subtests: {
17551796
"blarg": Subtest {
@@ -1786,6 +1827,7 @@ r#"
17861827
),
17871828
),
17881829
implementation_status: None,
1830+
tags: None,
17891831
},
17901832
},
17911833
},
@@ -1815,6 +1857,7 @@ r#"
18151857
is_disabled: false,
18161858
expected: None,
18171859
implementation_status: None,
1860+
tags: None,
18181861
},
18191862
subtests: {
18201863
":": Subtest {
@@ -1851,6 +1894,7 @@ r#"
18511894
),
18521895
),
18531896
implementation_status: None,
1897+
tags: None,
18541898
},
18551899
},
18561900
},
@@ -1914,6 +1958,105 @@ r#"
19141958
),
19151959
),
19161960
implementation_status: None,
1961+
tags: None,
1962+
},
1963+
subtests: {},
1964+
},
1965+
),
1966+
),
1967+
errs: [],
1968+
}
1969+
"###
1970+
);
1971+
assert_debug_snapshot!(
1972+
parser().parse(
1973+
r#"
1974+
[this_is_tagged.https.html]
1975+
tags: [webgpu, webgpu-long]
1976+
expected: [PASS, TIMEOUT]
1977+
"#
1978+
),
1979+
@r###"
1980+
ParseResult {
1981+
output: Some(
1982+
(
1983+
"this_is_tagged.https.html",
1984+
Test {
1985+
properties: TestProps {
1986+
is_disabled: false,
1987+
expected: Some(
1988+
ExpandedPropertyValue(
1989+
{
1990+
Windows: {
1991+
Debug: [
1992+
Pass,
1993+
Timeout,
1994+
],
1995+
Optimized: [
1996+
Pass,
1997+
Timeout,
1998+
],
1999+
},
2000+
Linux: {
2001+
Debug: [
2002+
Pass,
2003+
Timeout,
2004+
],
2005+
Optimized: [
2006+
Pass,
2007+
Timeout,
2008+
],
2009+
},
2010+
MacOs: {
2011+
Debug: [
2012+
Pass,
2013+
Timeout,
2014+
],
2015+
Optimized: [
2016+
Pass,
2017+
Timeout,
2018+
],
2019+
},
2020+
},
2021+
),
2022+
),
2023+
implementation_status: None,
2024+
tags: Some(
2025+
ExpandedPropertyValue(
2026+
{
2027+
Windows: {
2028+
Debug: [
2029+
"webgpu",
2030+
"webgpu-long",
2031+
],
2032+
Optimized: [
2033+
"webgpu",
2034+
"webgpu-long",
2035+
],
2036+
},
2037+
Linux: {
2038+
Debug: [
2039+
"webgpu",
2040+
"webgpu-long",
2041+
],
2042+
Optimized: [
2043+
"webgpu",
2044+
"webgpu-long",
2045+
],
2046+
},
2047+
MacOs: {
2048+
Debug: [
2049+
"webgpu",
2050+
"webgpu-long",
2051+
],
2052+
Optimized: [
2053+
"webgpu",
2054+
"webgpu-long",
2055+
],
2056+
},
2057+
},
2058+
),
2059+
),
19172060
},
19182061
subtests: {},
19192062
},

moz-webgpu-cts/src/wpt/metadata/properties.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ impl<T> ExpandedPropertyValue<T> {
290290
let Self(inner) = self;
291291
inner
292292
}
293+
294+
pub(crate) fn as_ref(&self) -> ExpandedPropertyValue<&T> {
295+
ExpandedPropertyValue::from_query(|platform, build_profile| {
296+
&self[(platform, build_profile)]
297+
})
298+
}
293299
}
294300

295301
impl<T> ExpandedPropertyValue<T> {

0 commit comments

Comments
 (0)