Update web-platform-tests to revision b'1d9b01e2fad6af3a057d571b1e088e15fa9bc8e6'

This commit is contained in:
WPT Sync Bot 2023-04-07 01:27:34 +00:00
parent cfef75c99b
commit bb34f95b33
1683 changed files with 37170 additions and 4252 deletions

View file

@ -28,13 +28,14 @@
#
# * Test the tests, add new ones to Git, remove deleted ones from Git, etc.
from typing import Any, List, Mapping, MutableMapping, Optional
from typing import Any, List, Mapping, MutableMapping, Optional, Tuple
import re
import collections
import dataclasses
import enum
import importlib
import itertools
import os
import pathlib
import sys
@ -71,6 +72,43 @@ def _escapeJS(string: str) -> str:
return string
def _unroll(text: str) -> str:
"""Unrolls text with all possible permutations of the parameter lists.
Example:
>>> print _unroll('f = {<a | b>: <1 | 2 | 3>};')
// a
f = {a: 1};
f = {a: 2};
f = {a: 3};
// b
f = {b: 1};
f = {b: 2};
f = {b: 3};
"""
patterns = [] # type: List[Tuple[str, List[str]]]
while match := re.search(r'<([^>]+)>', text):
key = f'@unroll_pattern_{len(patterns)}'
values = text[match.start(1):match.end(1)]
text = text[:match.start(0)] + key + text[match.end(0):]
patterns.append((key, [value.strip() for value in values.split('|')]))
def unroll_patterns(text: str,
patterns: List[Tuple[str, List[str]]],
label: Optional[str] = None) -> List[str]:
if not patterns:
return [text]
patterns = patterns.copy()
key, values = patterns.pop(0)
return (['// ' + label] if label else []) + list(
itertools.chain.from_iterable(
unroll_patterns(text.replace(key, value), patterns, value)
for value in values))
result = '\n'.join(unroll_patterns(text, patterns))
return result
def _expand_nonfinite(method: str, argstr: str, tail: str) -> str:
"""
>>> print _expand_nonfinite('f', '<0 a>, <0 b>', ';')
@ -133,6 +171,12 @@ def _get_test_sub_dir(name: str, name_to_sub_dir: Mapping[str, str]) -> str:
def _expand_test_code(code: str) -> str:
# Remove newlines if a backslash is found at end of line.
code = re.sub(r'\\\n\s*', '', code, flags=re.MULTILINE | re.DOTALL)
# Unroll expressions with a cross-product-style parameter expansion.
code = re.sub(r'@unroll ([^;]*;)', lambda m: _unroll(m.group(1)), code)
code = re.sub(r'@nonfinite ([^(]+)\(([^)]+)\)(.*)', lambda m:
_expand_nonfinite(m.group(1), m.group(2), m.group(3)),
code) # Must come before '@assert throws'.
@ -210,11 +254,14 @@ def _get_canvas_size(test: Mapping[str, Any]):
return match.group('width'), match.group('height')
def _write_reference_test(templates: Mapping[str, str],
def _write_reference_test(is_js_ref: bool, templates: Mapping[str, str],
template_params: MutableMapping[str, str],
reference: str,
canvas_path: Optional[str],
ref_code: str, canvas_path: Optional[str],
offscreen_path: Optional[str]):
ref_code = ref_code.strip()
ref_code = textwrap.indent(ref_code, ' ') if is_js_ref else ref_code
ref_template_name = 'element_ref_test' if is_js_ref else 'html_ref_test'
code = template_params['code']
template_params['code'] = textwrap.indent(code, ' ')
if canvas_path:
@ -227,15 +274,15 @@ def _write_reference_test(templates: Mapping[str, str],
pathlib.Path(f'{offscreen_path}.w.html').write_text(
templates['worker_ref_test'] % template_params, 'utf-8')
template_params['code'] = textwrap.indent(reference.strip(), ' ')
template_params['code'] = ref_code
template_params['links'] = ''
template_params['fuzzy'] = ''
if canvas_path:
pathlib.Path(f'{canvas_path}-expected.html').write_text(
templates['element_ref_test'] % template_params, 'utf-8')
templates[ref_template_name] % template_params, 'utf-8')
if offscreen_path:
pathlib.Path(f'{offscreen_path}-expected.html').write_text(
templates['element_ref_test'] % template_params, 'utf-8')
templates[ref_template_name] % template_params, 'utf-8')
def _write_testharness_test(templates: Mapping[str, str],
@ -389,10 +436,17 @@ def _generate_test(test: Mapping[str, Any], templates: Mapping[str, str],
canvas_path += '-manual'
offscreen_path += '-manual'
reference = test.get('reference')
if reference is not None:
js_reference = test.get('reference')
html_reference = test.get('html_reference')
if js_reference is not None and html_reference is not None:
raise InvalidTestDefinitionError(
f'Test {name} is invalid, "reference" and "html_reference" can\'t '
'both be specified at the same time.')
ref_code = js_reference or html_reference
if ref_code is not None:
_write_reference_test(
templates, template_params, reference,
js_reference is not None, templates, template_params, ref_code,
canvas_path if html_canvas_cfg.enabled else None,
offscreen_path if offscreen_canvas_cfg.enabled else None)
else:
@ -456,7 +510,10 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
test['name'] += '.' + variant_name
test['code'] = test['code'] % variant_params
if 'reference' in test:
test['reference'] = test['reference'] % variant_params
test['reference'] = test['reference'] % variant_params
if 'html_reference' in test:
test['html_reference'] = (
test['html_reference'] % variant_params)
test.update(variant_params)
name = test['name']