Bug 1812477 [wpt PR 38178] - Fix string quotes consistency in canvas WPT tool scripts., a=testonly

Automatic update from web-platform-tests
Fix string quotes consistency in canvas WPT tool scripts.

The Python style guide recommends being consistent in using either
single or double quotes:
https://peps.python.org/pep-0008/#string-quotes.

Change-Id: Iecc60f412b92622c2154b9d610eb36b3f5e2c716
Bug: 1409873
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189389
Reviewed-by: Yi Xu <yiyix@chromium.org>
Commit-Queue: Jean-Philippe Gravel <jpgravel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1097125}

--

wpt-commits: 74f562fedb415b26e9266a9699ec477ca660709a
wpt-pr: 38178
This commit is contained in:
Jean-Philippe Gravel 2023-01-27 15:30:52 +00:00 коммит произвёл moz-wptsync-bot
Родитель 32c2bc9db4
Коммит 164461472e
2 изменённых файлов: 45 добавлений и 45 удалений

Просмотреть файл

@ -129,18 +129,18 @@ def genTestUtils(TESTOUTPUTDIR: str, IMAGEOUTPUTDIR: str, TEMPLATEFILE: str,
doctest.testmod()
sys.exit()
templates = yaml.safe_load(open(TEMPLATEFILE, "r").read())
name_mapping = yaml.safe_load(open(NAME2DIRFILE, "r").read())
templates = yaml.safe_load(open(TEMPLATEFILE, 'r').read())
name_mapping = yaml.safe_load(open(NAME2DIRFILE, 'r').read())
tests = []
test_yaml_directory = "yaml/element"
test_yaml_directory = 'yaml/element'
if ISOFFSCREENCANVAS:
test_yaml_directory = "yaml/offscreen"
test_yaml_directory = 'yaml/offscreen'
TESTSFILES = [
os.path.join(test_yaml_directory, f)
for f in os.listdir(test_yaml_directory) if f.endswith(".yaml")
for f in os.listdir(test_yaml_directory) if f.endswith('.yaml')
]
for t in sum([yaml.safe_load(open(f, "r").read()) for f in TESTSFILES],
for t in sum([yaml.safe_load(open(f, 'r').read()) for f in TESTSFILES],
[]):
if 'DISABLED' in t:
continue
@ -166,7 +166,7 @@ def genTestUtils(TESTOUTPUTDIR: str, IMAGEOUTPUTDIR: str, TEMPLATEFILE: str,
# Ensure the test output directories exist.
testdirs = [TESTOUTPUTDIR, IMAGEOUTPUTDIR, MISCOUTPUTDIR]
for map_dir in set(name_mapping.values()):
testdirs.append("%s/%s" % (TESTOUTPUTDIR, map_dir))
testdirs.append('%s/%s' % (TESTOUTPUTDIR, map_dir))
for d in testdirs:
try:
os.mkdir(d)
@ -179,14 +179,14 @@ def genTestUtils(TESTOUTPUTDIR: str, IMAGEOUTPUTDIR: str, TEMPLATEFILE: str,
mapped_name = None
for mn in sorted(name_mapping.keys(), key=len, reverse=True):
if name.startswith(mn):
mapped_name = "%s/%s" % (name_mapping[mn], name)
mapped_name = '%s/%s' % (name_mapping[mn], name)
break
if not mapped_name:
print("LIKELY ERROR: %s has no defined target directory mapping" %
print('LIKELY ERROR: %s has no defined target directory mapping' %
name)
return None
if 'manual' in test:
mapped_name += "-manual"
mapped_name += '-manual'
return mapped_name
def expand_test_code(code: str) -> str:
@ -230,7 +230,7 @@ def genTestUtils(TESTOUTPUTDIR: str, IMAGEOUTPUTDIR: str, TEMPLATEFILE: str,
code = re.sub(r' @moz-todo', '', code)
code = re.sub(r'@moz-UniversalBrowserRead;', "", code)
code = re.sub(r'@moz-UniversalBrowserRead;', '', code)
assert ('@' not in code)
@ -241,10 +241,10 @@ def genTestUtils(TESTOUTPUTDIR: str, IMAGEOUTPUTDIR: str, TEMPLATEFILE: str,
test = tests[i]
name = test['name']
print("\r(%s)" % name, " " * 32, "\t")
print('\r(%s)' % name, ' ' * 32, '\t')
if name in used_tests:
print("Test %s is defined twice" % name)
print('Test %s is defined twice' % name)
used_tests[name] = 1
mapped_name = map_name(name)
@ -263,7 +263,7 @@ def genTestUtils(TESTOUTPUTDIR: str, IMAGEOUTPUTDIR: str, TEMPLATEFILE: str,
if test.get('expected', '') == 'green' and re.search(
r'@assert pixel .* 0,0,0,0;', test['code']):
print("Probable incorrect pixel test in %s" % name)
print('Probable incorrect pixel test in %s' % name)
code = expand_test_code(test['code'])
@ -272,26 +272,26 @@ def genTestUtils(TESTOUTPUTDIR: str, IMAGEOUTPUTDIR: str, TEMPLATEFILE: str,
expected = test['expected']
expected_img = None
if expected == 'green':
expected_img = "/images/green-100x50.png"
expected_img = '/images/green-100x50.png'
elif expected == 'clear':
expected_img = "/images/clear-100x50.png"
expected_img = '/images/clear-100x50.png'
else:
if ';' in expected:
print("Found semicolon in %s" % name)
print('Found semicolon in %s' % name)
expected = re.sub(
r'^size (\d+) (\d+)',
r'surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, \1, \2)'
r'\ncr = cairo.Context(surface)', expected)
if mapped_name.endswith("-manual"):
png_name = mapped_name[:-len("-manual")]
if mapped_name.endswith('-manual'):
png_name = mapped_name[:-len('-manual')]
else:
png_name = mapped_name
expected += "\nsurface.write_to_png('%s/%s.png')\n" % (
IMAGEOUTPUTDIR, png_name)
eval(compile(expected, '<test %s>' % test['name'], 'exec'), {},
{'cairo': cairo})
expected_img = "%s.png" % name
expected_img = '%s.png' % name
if expected_img:
expectation_html = (
@ -336,7 +336,7 @@ def genTestUtils(TESTOUTPUTDIR: str, IMAGEOUTPUTDIR: str, TEMPLATEFILE: str,
src = '../images/%s' % src
images += ('<svg><image xlink:href="%s" id="%s" class="resource">'
'</svg>\n' % (src, img_id))
images = images.replace("../images/", "/images/")
images = images.replace('../images/', '/images/')
fonts = ''
fonthack = ''

Просмотреть файл

@ -131,16 +131,16 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
doctest.testmod()
sys.exit()
templates = yaml.safe_load(open(TEMPLATEFILE, "r").read())
name_mapping = yaml.safe_load(open(NAME2DIRFILE, "r").read())
templates = yaml.safe_load(open(TEMPLATEFILE, 'r').read())
name_mapping = yaml.safe_load(open(NAME2DIRFILE, 'r').read())
tests = []
test_yaml_directory = "yaml-new"
test_yaml_directory = 'yaml-new'
TESTSFILES = [
os.path.join(test_yaml_directory, f)
for f in os.listdir(test_yaml_directory) if f.endswith(".yaml")
for f in os.listdir(test_yaml_directory) if f.endswith('.yaml')
]
for t in sum([yaml.safe_load(open(f, "r").read()) for f in TESTSFILES],
for t in sum([yaml.safe_load(open(f, 'r').read()) for f in TESTSFILES],
[]):
if 'DISABLED' in t:
continue
@ -169,8 +169,8 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
OFFSCREENCANVASIMAGEOUTPUTDIR, MISCOUTPUTDIR
]
for map_dir in set(name_mapping.values()):
testdirs.append("%s/%s" % (CANVASOUTPUTDIR, map_dir))
testdirs.append("%s/%s" % (OFFSCREENCANVASOUTPUTDIR, map_dir))
testdirs.append('%s/%s' % (CANVASOUTPUTDIR, map_dir))
testdirs.append('%s/%s' % (OFFSCREENCANVASOUTPUTDIR, map_dir))
for d in testdirs:
try:
os.mkdir(d)
@ -183,14 +183,14 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
mapped_name = None
for mn in sorted(name_mapping.keys(), key=len, reverse=True):
if name.startswith(mn):
mapped_name = "%s/%s" % (name_mapping[mn], name)
mapped_name = '%s/%s' % (name_mapping[mn], name)
break
if not mapped_name:
print("LIKELY ERROR: %s has no defined target directory mapping" %
print('LIKELY ERROR: %s has no defined target directory mapping' %
name)
return name
if 'manual' in test:
mapped_name += "-manual"
mapped_name += '-manual'
return mapped_name
def expand_test_code(code: str) -> str:
@ -234,7 +234,7 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
code = re.sub(r' @moz-todo', '', code)
code = re.sub(r'@moz-UniversalBrowserRead;', "", code)
code = re.sub(r'@moz-UniversalBrowserRead;', '', code)
assert ('@' not in code)
@ -255,10 +255,10 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
OffscreenCanvas_test = True
name = test['name']
print("\r(%s)" % name, " " * 32, "\t")
print('\r(%s)' % name, ' ' * 32, '\t')
if name in used_tests:
print("Test %s is defined twice" % name)
print('Test %s is defined twice' % name)
used_tests[name] = 1
mapped_name = map_name(name)
@ -273,7 +273,7 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
if test.get('expected', '') == 'green' and re.search(
r'@assert pixel .* 0,0,0,0;', test['code']):
print("Probable incorrect pixel test in %s" % name)
print('Probable incorrect pixel test in %s' % name)
code_canvas = expand_test_code(test['code']).strip()
@ -282,19 +282,19 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
expected = test['expected']
expected_img = None
if expected == 'green':
expected_img = "/images/green-100x50.png"
expected_img = '/images/green-100x50.png'
elif expected == 'clear':
expected_img = "/images/clear-100x50.png"
expected_img = '/images/clear-100x50.png'
else:
if ';' in expected:
print("Found semicolon in %s" % name)
print('Found semicolon in %s' % name)
expected = re.sub(
r'^size (\d+) (\d+)',
r'surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, \1, \2)'
r'\ncr = cairo.Context(surface)', expected)
if mapped_name.endswith("-manual"):
png_name = mapped_name[:-len("-manual")]
if mapped_name.endswith('-manual'):
png_name = mapped_name[:-len('-manual')]
else:
png_name = mapped_name
expected_canvas = (expected +
@ -312,7 +312,7 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
'<test %s>' % test['name'], 'exec'), {},
{'cairo': cairo})
expected_img = "%s.png" % name
expected_img = '%s.png' % name
if expected_img:
expectation_html = (
@ -357,7 +357,7 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
src = '../images/%s' % src
images += ('<svg><image xlink:href="%s" id="%s" class="resource">'
'</svg>\n' % (src, img_id))
images = images.replace("../images/", "/images/")
images = images.replace('../images/', '/images/')
fonts = ''
fonthack = ''
@ -425,11 +425,11 @@ def genTestUtils_union(TEMPLATEFILE: str, NAME2DIRFILE: str) -> None:
'%s/%s%s.worker.js' %
(OFFSCREENCANVASOUTPUTDIR, mapped_name, name_variant), 'w',
'utf-8')
if ("then(t_pass, t_fail);" in code_canvas):
if ('then(t_pass, t_fail);' in code_canvas):
temp_offscreen = templates['w3coffscreencanvas'].replace(
"t.done();\n", "")
't.done();\n', '')
temp_worker = templates['w3cworker'].replace(
"t.done();\n", "")
't.done();\n', '')
f_html.write(temp_offscreen % template_params)
timeout = ('// META: timeout=%s\n' %
test['timeout'] if 'timeout' in test else '')