Skip to content

Commit

Permalink
Integrate script to generate object-view-box tests to ./wpt update-bu…
Browse files Browse the repository at this point in the history
…ilt (web-platform-tests#36130)

Move both this script and shell scripts for object-fit into a tools/
subdirectory rather than support/, following the convention elsewhere.

Also make use of some f-strings for readability.
  • Loading branch information
foolip authored Mar 22, 2023
1 parent 308366a commit 50d4ff2
Show file tree
Hide file tree
Showing 21 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import os
import sys

HERE = os.path.abspath(os.path.dirname(__file__))

def generate_file(source, destination, tag, name, image_source):
file = open(source)
lines = file.read()
file.close()
with open(os.path.join(HERE, source)) as file:
lines = file.read()

replaced_lines = lines.replace('__TAG__',
tag).replace('__NAME__', name).replace(
'__IMAGE_SOURCE__', image_source)
replaced_lines = '<!-- This is an autogen file. Run support/generate_object_view_box_tests.py to update -->\n' + replaced_lines
new_file = open(destination, "w")
new_file.write(replaced_lines)
new_file.close()
with open(os.path.join(HERE, destination), "w") as new_file:
new_file.write(replaced_lines)


def generate_for_object_fit(object_fit):
Expand All @@ -24,14 +24,12 @@ def generate_for_object_fit(object_fit):
]

for i in range(len(names)):
source = 'object-view-box-fit-' + object_fit + '-template.html'
destination = '../object-view-box-fit-' + object_fit + '-' + names[
i] + '.html'
source = f'object-view-box-fit-{object_fit}-template.html'
destination = f'../object-view-box-fit-{object_fit}-{names[i]}.html'
generate_file(source, destination, tags[i], names[i], image_sources[i])

source = 'object-view-box-fit-' + object_fit + '-ref-template.html'
destination = '../object-view-box-fit-' + object_fit + '-' + names[
i] + '-ref.html'
source = f'object-view-box-fit-{object_fit}-ref-template.html'
destination = f'../object-view-box-fit-{object_fit}-{names[i]}-ref.html'
generate_file(source, destination, tags[i], names[i], image_sources[i])


Expand All @@ -45,12 +43,11 @@ def generate_for_writing_mode():

for i in range(len(names)):
source = 'object-view-box-writing-mode-template.html'
destination = '../object-view-box-writing-mode-' + names[i] + '.html'
destination = f'../object-view-box-writing-mode-{names[i]}.html'
generate_file(source, destination, tags[i], names[i], image_sources[i])

source = 'object-view-box-writing-mode-ref-template.html'
destination = '../object-view-box-writing-mode-' + names[
i] + '-ref.html'
destination = f'../object-view-box-writing-mode-{names[i]}-ref.html'
generate_file(source, destination, tags[i], names[i], image_sources[i])


Expand Down
1 change: 1 addition & 0 deletions tools/ci/update_built.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"conformance-checkers/tools/ins-del-datetime.py",
"conformance-checkers/tools/picture.py",
"conformance-checkers/tools/url.py"],
"css-images": ["css/css-images/tools/generate_object_view_box_tests.py"],
"css-ui": ["css/css-ui/tools/appearance-build-webkit-reftests.py"],
# FIXME: https://github.com/web-platform-tests/wpt/issues/32060
# "css-text": ["css/css-text/line-breaking/tools/generate-segment-break-transformation-rules-tests.py"],
Expand Down

0 comments on commit 50d4ff2

Please sign in to comment.