WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-223112-20210312104240.patch (text/plain), 43.98 KB, created by
Kimmo Kinnunen
on 2021-03-12 00:42:42 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Kimmo Kinnunen
Created:
2021-03-12 00:42:42 PST
Size:
43.98 KB
patch
obsolete
>Subversion Revision: 274287 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 1fc71c479d3307555d409ca6ced7330eb00928e8..591af8e8b430cdcf5002d3f479f15d434b919b73 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,52 @@ >+2021-03-12 Kimmo Kinnunen <kkinnunen@apple.com> >+ >+ Make WebGL conformance test update script more usable and consistent >+ https://bugs.webkit.org/show_bug.cgi?id=223112 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Moves the script LayoutTests/webgl/generate-webgl-tests over >+ unused and stale Tools/Scripts/update-webgl-conformance-tests >+ >+ Fixes the script to: >+ - to support generation of the test driver .html files with webglVersion=2 >+ - to copy the "beta" 1.0.3/2.0.0 tests for the features that are implemented >+ in WebKit. These are now copied to webgl/sdk dir, previously they were >+ manually copied to webgl/ dir, making it hard to maintain the tests since they >+ could not be cleaned up by removing the dir and regenerating. >+ - to support copying all the tests at the same time. Previously each >+ individual suites (1.0.3, 2.0.0 and the beta tests) would be copied >+ in different invocations, leading to errors and omissions to run when >+ something changes, such as the templates. >+ - supports generation of the directories from scratch, so that no stale files >+ such as expectations, driver .html files or test suite content is left. >+ - automatically filter files that do not need to be copied (deqp/compiler.jar, ...) >+ - try to adopt a style somewhat consistent with other WebKit python scripts >+ >+ * Scripts/update-webgl-conformance-tests: >+ * Scripts/webkitpy/to_be_moved/__init__.py: Removed. >+ * Scripts/webkitpy/to_be_moved/update_webgl_conformance_tests.py: Removed. >+ * Scripts/webkitpy/to_be_moved/update_webgl_conformance_tests_unittest.py: Removed. >+ * Scripts/webkitpy/update_webgl_conformance_tests_lib/main.py: Added. >+ (_make_ignore_fnmatch_rule_matcher): >+ (_make_ignore_fnmatch_rule_matcher.match_rules): >+ (_copy_tree): >+ (_WebGLTest): >+ (_parse_webgl_tests): >+ (_filter_webgl_test_paths_for_suite_version): >+ (_generate_webkit_webgl_tests): >+ (_find_expectations_for_removed_tests): >+ (main): >+ * Scripts/webkitpy/update_webgl_conformance_tests_lib/webgl-expectation-template.txt: Renamed from LayoutTests/webgl/resources/webgl-expectation-template.txt. >+ * Scripts/webkitpy/update_webgl_conformance_tests_lib/webgl-test-driver-template.html: Renamed from LayoutTests/webgl/resources/webgl-wrapper-template.html. >+ * Scripts/webkitpy/update_webgl_conformance_tests_lib/webkit-webgl-test-harness-template.js: Added. >+ (window.layoutTestController.window.console.log): >+ (window.layoutTestController.window.console.error): >+ (list): >+ (log): >+ (window.webglTestHarness.reportResults): >+ (window.webglTestHarness.notifyFinished): >+ > 2021-03-11 Chris Dumez <cdumez@apple.com> > > Introduce WorkQueue::dispatchSync() >diff --git a/Tools/Scripts/update-webgl-conformance-tests b/Tools/Scripts/update-webgl-conformance-tests >index b93083645afad43b3f8c42c8678c05280a1d4511..c14e3a9eea10eea909c26c2296ba17ac625761f6 100755 >--- a/Tools/Scripts/update-webgl-conformance-tests >+++ b/Tools/Scripts/update-webgl-conformance-tests >@@ -1,4 +1,4 @@ >-#!/usr/bin/env python >+#!/usr/bin/env python3 > # Copyright (C) 2010 Google Inc. All rights reserved. > # > # Redistribution and use in source and binary forms, with or without >@@ -27,10 +27,27 @@ > # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE > # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > >-"""Wrapper around webkitpy/layout_tests/update-webgl-conformance-tests.py""" >+"""Generates WebKit WebGL layout tests from the Khronos WebGL conformance tests""" >+ >+# To use this, get a copy of the WebGL conformance tests then run this script >+# eg. >+# >+# cd ~/temp >+# git clone git://github.com/KhronosGroup/WebGL.git >+# mkdir backup >+# mv ~/WebKit/LayoutTests/webgl/{1.0.3,2.0.0,sdk} backup/ >+# ~/WebKit/Tools/Scripts/update-webgl-conformance-tests ~/temp/WebGL >+# ~/WebKit/Tools/Scripts/run-webkit-tests --debug --webgl --order=random webgl >+# ~/WebKit/Tools/Scripts/run-webkit-tests --release --webgl --order=random webgl >+# ~/WebKit/Tools/Scripts/check-for-duplicated-platform-test-results -n 2>&1 | grep webgl >+# [ Update TestExpectations ] >+# [ Check in the result ] >+# >+# Note: The script is currently not tested to be run on Windows. > >-import webkitpy.to_be_moved.update_webgl_conformance_tests > import sys > >+from webkitpy.update_webgl_conformance_tests_lib.main import main >+ > if __name__ == '__main__': >- sys.exit(webkitpy.to_be_moved.update_webgl_conformance_tests.main()) >+ sys.exit(main()) >diff --git a/Tools/Scripts/webkitpy/to_be_moved/__init__.py b/Tools/Scripts/webkitpy/to_be_moved/__init__.py >deleted file mode 100644 >index c0528b7833309227dc0ec89f800471dc7674d224..0000000000000000000000000000000000000000 >--- a/Tools/Scripts/webkitpy/to_be_moved/__init__.py >+++ /dev/null >@@ -1,10 +0,0 @@ >-# Required for Python to search this directory for module files >-# This directory houses Python modules that do not yet have a proper home. >-# >-# Some of the Python modules in this directory aren't really part of webkitpy >-# in the sense that they're not classes that are meant to be used as part of >-# the webkitpy library. Instead, they're a bunch of helper code for individual >-# scripts in in Tools/Scripts. >-# >-# Really, all this code should either be refactored or moved somewhere else, >-# hence the somewhat lame name for this directory. >diff --git a/Tools/Scripts/webkitpy/to_be_moved/update_webgl_conformance_tests.py b/Tools/Scripts/webkitpy/to_be_moved/update_webgl_conformance_tests.py >deleted file mode 100644 >index 787acaf2635b74c96ca3b6cc9c036f08c5ff07c4..0000000000000000000000000000000000000000 >--- a/Tools/Scripts/webkitpy/to_be_moved/update_webgl_conformance_tests.py >+++ /dev/null >@@ -1,156 +0,0 @@ >-# Copyright (C) 2010 Google Inc. All rights reserved. >-# >-# Redistribution and use in source and binary forms, with or without >-# modification, are permitted provided that the following conditions >-# are met: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. Redistributions in binary form must reproduce the above copyright >-# notice, this list of conditions and the following disclaimer in the >-# documentation and/or other materials provided with the distribution. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >-# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- >-import glob >-import logging >-import optparse >-import os >-import re >-import sys >-from webkitpy.common.checkout import scm >-from webkitpy.common.system.filesystem import FileSystem >-from webkitpy.common.system.executive import Executive >- >- >-_log = logging.getLogger(__name__) >- >- >-def remove_first_line_comment(text): >- return re.compile(r'^<!--.*?-->\s*', re.DOTALL).sub('', text) >- >- >-def translate_includes(text): >- # Mapping of single filename to relative path under WebKit root. >- # Assumption: these filenames are globally unique. >- include_mapping = { >- "js-test-pre.js": "../../../resources", >- "js-test-post.js": "../../../resources", >- "desktop-gl-constants.js": "resources", >- } >- >- for filename, path in include_mapping.items(): >- search = r'(?:[^"\'= ]*/)?' + re.escape(filename) >- # We use '/' instead of os.path.join in order to produce consistent >- # output cross-platform. >- replace = path + '/' + filename >- text = re.sub(search, replace, text) >- >- return text >- >- >-def translate_khronos_test(text): >- """ >- This method translates the contents of a Khronos test to a WebKit test. >- """ >- >- translateFuncs = [ >- remove_first_line_comment, >- translate_includes, >- ] >- >- for f in translateFuncs: >- text = f(text) >- >- return text >- >- >-def update_file(in_filename, out_dir): >- # check in_filename exists >- # check out_dir exists >- out_filename = os.path.join(out_dir, os.path.basename(in_filename)) >- >- _log.debug("Processing " + in_filename) >- with open(in_filename, 'r') as in_file: >- with open(out_filename, 'w') as out_file: >- out_file.write(translate_khronos_test(in_file.read())) >- >- >-def update_directory(in_dir, out_dir): >- for filename in glob.glob(os.path.join(in_dir, '*.html')): >- update_file(os.path.join(in_dir, filename), out_dir) >- >- >-def default_out_dir(): >- detector = scm.SCMDetector(FileSystem(), Executive()) >- current_scm = detector.detect_scm_system(os.path.dirname(sys.argv[0])) >- if not current_scm: >- return os.getcwd() >- root_dir = current_scm.checkout_root >- if not root_dir: >- return os.getcwd() >- out_dir = os.path.join(root_dir, "LayoutTests/fast/canvas/webgl") >- if os.path.isdir(out_dir): >- return out_dir >- return os.getcwd() >- >- >-def configure_logging(options): >- """Configures the logging system.""" >- log_fmt = '%(levelname)s: %(message)s' >- log_datefmt = '%y%m%d %H:%M:%S' >- log_level = logging.INFO >- if options.verbose: >- log_fmt = ('%(asctime)s %(filename)s:%(lineno)-4d %(levelname)s ' >- '%(message)s') >- log_level = logging.DEBUG >- logging.basicConfig(level=log_level, format=log_fmt, >- datefmt=log_datefmt) >- >- >-def option_parser(): >- usage = "usage: %prog [options] (input file or directory)" >- parser = optparse.OptionParser(usage=usage) >- parser.add_option('-v', '--verbose', >- action='store_true', >- default=False, >- help='include debug-level logging') >- parser.add_option('-o', '--output', >- action='store', >- type='string', >- default=default_out_dir(), >- metavar='DIR', >- help='specify an output directory to place files ' >- 'in [default: %default]') >- return parser >- >- >-def main(): >- parser = option_parser() >- (options, args) = parser.parse_args() >- configure_logging(options) >- >- if len(args) == 0: >- _log.error("Must specify an input directory or filename.") >- parser.print_help() >- return 1 >- >- in_name = args[0] >- if os.path.isfile(in_name): >- update_file(in_name, options.output) >- elif os.path.isdir(in_name): >- update_directory(in_name, options.output) >- else: >- _log.error("'%s' is not a directory or a file.", in_name) >- return 2 >- >- return 0 >diff --git a/Tools/Scripts/webkitpy/to_be_moved/update_webgl_conformance_tests_unittest.py b/Tools/Scripts/webkitpy/to_be_moved/update_webgl_conformance_tests_unittest.py >deleted file mode 100644 >index ee9fb969b39d48d26d3ab77777b3ce44af9a5e4e..0000000000000000000000000000000000000000 >--- a/Tools/Scripts/webkitpy/to_be_moved/update_webgl_conformance_tests_unittest.py >+++ /dev/null >@@ -1,96 +0,0 @@ >-# Copyright (C) 2010 Google Inc. All rights reserved. >-# >-# Redistribution and use in source and binary forms, with or without >-# modification, are permitted provided that the following conditions are >-# met: >-# >-# * Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# * Redistributions in binary form must reproduce the above >-# copyright notice, this list of conditions and the following disclaimer >-# in the documentation and/or other materials provided with the >-# distribution. >-# * Neither the name of Google Inc. nor the names of its >-# contributors may be used to endorse or promote products derived from >-# this software without specific prior written permission. >-# >-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- >-"""Unit tests for update_webgl_conformance_tests.""" >- >-import unittest >-from webkitpy.to_be_moved import update_webgl_conformance_tests as webgl >- >- >-def construct_script(name): >- return "<script src=\"" + name + "\"></script>\n" >- >- >-def construct_style(name): >- return "<link rel=\"stylesheet\" href=\"" + name + "\">" >- >- >-class TestTranslation(unittest.TestCase): >- def assert_unchanged(self, text): >- self.assertEqual(text, webgl.translate_khronos_test(text)) >- >- def assert_translate(self, input, output): >- self.assertEqual(output, webgl.translate_khronos_test(input)) >- >- def test_simple_unchanged(self): >- self.assert_unchanged("") >- self.assert_unchanged("<html></html>") >- >- def test_header_strip(self): >- single_line_header = "<!-- single line header. -->" >- multi_line_header = """<!-- this is a multi-line >- header. it should all be removed too. >- -->""" >- text = "<html></html>" >- self.assert_translate(single_line_header, "") >- self.assert_translate(single_line_header + text, text) >- self.assert_translate(multi_line_header + text, text) >- >- def dont_strip_other_headers(self): >- self.assert_unchanged("<html>\n<!-- don't remove comments on other lines. -->\n</html>") >- >- def test_include_rewriting(self): >- # Mappings to None are unchanged >- styles = { >- "fail.css": None, >- "resources/stylesheet.css": None, >- "../resources/style.css": None, >- } >- scripts = { >- "../resources/js-test-pre.js": "../../../resources/js-test-pre.js", >- "../resources/js-test-post.js": "../../../resources/js-test-post.js", >- "../resources/desktop-gl-constants.js": "resources/desktop-gl-constants.js", >- >- "resources/shadow-offset.js": None, >- "../resources/js-test-post-async.js": None, >- } >- >- input_text = "" >- output_text = "" >- for input, output in styles.items(): >- input_text += construct_style(input) >- output_text += construct_style(output if output else input) >- for input, output in scripts.items(): >- input_text += construct_script(input) >- output_text += construct_script(output if output else input) >- >- head = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">\n<html>\n<head>\n' >- foot = '</head>\n<body>\n</body>\n</html>' >- input_text = head + input_text + foot >- output_text = head + output_text + foot >- self.assert_translate(input_text, output_text) >diff --git a/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/main.py b/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/main.py >new file mode 100755 >index 0000000000000000000000000000000000000000..77dc91db7bec4a816c38e06a665d7a97f0389c4a >--- /dev/null >+++ b/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/main.py >@@ -0,0 +1,308 @@ >+#!/usr/bin/env python3 >+# Copyright (C) 2013 Google Inc. All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions are >+# met: >+# >+# * Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# * Redistributions in binary form must reproduce the above >+# copyright notice, this list of conditions and the following disclaimer >+# in the documentation and/or other materials provided with the >+# distribution. >+# * Neither the name of Google Inc. nor the names of its >+# contributors may be used to endorse or promote products derived from >+# this software without specific prior written permission. >+# >+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ >+"""Generates WebKit WebGL layout tests from the Khronos WebGL conformance tests >+ >+ To use this, get a copy of the WebGL conformance tests then run this script >+ eg. >+ cd ~/temp >+ git clone git://github.com/KhronosGroup/WebGL.git >+ mkdir backup >+ mv ~/WebKit/LayoutTests/webgl/{1.0.3,2.0.0,sdk} backup/ >+ ~/WebKit/Tools/Scripts/generate-webgl-tests ~/temp/WebGL >+ ~/WebKit/Tools/Scripts/run-webkit-tests --debug --webgl --order=random webgl >+ ~/WebKit/Tools/Scripts/run-webkit-tests --release --webgl --order=random webgl >+ ~/WebKit/Tools/Scripts/check-for-duplicated-platform-test-results -n 2>&1 | grep webgl >+ [ Update TestExpectations ] >+ [ Check in the result ] >+""" >+ >+# Note: The script is currently not tested to be run on Windows. >+# To start implementing a new WebGL feature, add the test to _sdk_patterns and run >+# the script as above. >+# >+# To add a new WebGL test suite, edit the main(). >+# >+# python3 -m mypy main.py && python3 -m black main.py --line-length 200 >+ >+import argparse >+import os >+import shutil >+import sys >+ >+from distutils.version import StrictVersion as Version >+from fnmatch import fnmatch >+from pathlib import Path >+from typing import Callable, Tuple, Iterable, Union, NamedTuple, Optional, Generator >+ >+_tool_dir = Path(__file__).parent >+_layout_tests_dir = Path(__file__).parent.parent.parent.parent.parent / "LayoutTests" >+ >+_use_verbose_output = False >+ >+_IgnoredFilenameMatcher = Callable[[Path], bool] >+ >+ >+# Creates an ignore file name pattern matcher based on list of match rules. >+# Rule iteration order is the order of least specific to most specific rule. >+# Empty list means do not ignore. >+# If rule is str and it matches, it means ignore if no more specific rule matches. >+# If rule is a tuple and its first element matches, it it means do not ignore if no more specific rule matches. >+def _make_ignore_fnmatch_rule_matcher(rules: Iterable[Union[str, Tuple[str]]]) -> _IgnoredFilenameMatcher: >+ def match_rules(name: Path) -> bool: >+ should_filter = None >+ for rule in rules: >+ pattern: str = rule if isinstance(rule, str) else rule[0] >+ if fnmatch(str(name), pattern): >+ should_filter = isinstance(rule, str) >+ return should_filter is True >+ >+ return match_rules >+ >+ >+_conformance_patterns = _make_ignore_fnmatch_rule_matcher( >+ [ >+ ".git", >+ "*.pyc", >+ "tmp*", >+ "*/deqp/build.py", >+ "*/deqp/compiler_additional_extern.js", >+ "*/deqp/compiler.jar", >+ "*/deqp/genHTMLfromTest.py", >+ "*/deqp/run-closure.sh", >+ "*/deqp/temp_externs*", >+ "*/deqp/test-webgl2.js", >+ "*/deqp/test-webgl2.sh", >+ ] >+) >+ >+_sdk_patterns = _make_ignore_fnmatch_rule_matcher( >+ [ >+ "*", # Ignore all except the ones we want. Positive matches are in tuples (). >+ ("*/js/tests/ext-float-blend.js",), >+ ("*/js/tests/compressed-texture-utils.js",), >+ ("*/js/js-test-pre.js",), >+ ("*/js/webgl-test-utils.js",), >+ ("*/js/js-test-post.js",), >+ ("*/resources/js-test-style.css",), >+ ("*/conformance/extensions/ext-float-blend.html",), >+ ("*/conformance/extensions/ext-texture-compression-rgtc.html",), >+ ("*/conformance/extensions/khr-parallel-shader-compile.html",), >+ ("*/conformance/extensions/oes-fbo-render-mipmap.html",), >+ ("*/conformance/extensions/s3tc-and-rgtc.html",), >+ ("*/conformance/extensions/webgl-multi-draw.html",), >+ ("*/conformance2/uniforms/gl-uniform-arrays-sub-source.html",), >+ ] >+) >+ >+ >+def _copy_tree(src: Path, dst: Path, ignore: Optional[_IgnoredFilenameMatcher] = None): >+ """Recursively copy a directory tree""" >+ names = os.listdir(src) >+ for name in names: >+ src_name = src / name >+ dst_name = dst / name >+ >+ if src_name.is_dir(): >+ _copy_tree(src_name, dst_name, ignore) >+ else: >+ if ignore is not None and ignore(src_name): >+ if _use_verbose_output: >+ print("Ignoring: %s" % (src_name)) >+ continue >+ if _use_verbose_output: >+ print("Copying: %s -> %s" % (src_name, dst_name)) >+ dst.mkdir(parents=True, exist_ok=True) >+ shutil.copyfile(src_name, dst_name) >+ >+ >+class _WebGLTest(NamedTuple): >+ path: Path >+ min_version: Version >+ max_version: Version >+ >+ >+def _parse_webgl_tests(test_list_root: Path, test_list: Path, min_version: Version, max_version: Version) -> Generator[_WebGLTest, None, None]: >+ prefix = test_list.parent >+ with test_list.open("r") as f: >+ lines = f.readlines() >+ for line_number, line in enumerate(lines): >+ line = line.strip() >+ if len(line) <= 0 or line.startswith("#") or line.startswith(";") or line.startswith("//"): >+ continue >+ test_min_version = min_version >+ test_max_version = max_version >+ test_name = "" >+ args = iter(line.split()) >+ for arg in args: >+ if arg.startswith("-"): >+ if arg == "--slow": >+ pass >+ elif arg == "--min-version": >+ test_min_version = Version(next(args)) >+ elif arg == "--max-version": >+ test_max_version = Version(next(args)) >+ else: >+ raise Exception("%s:%d unknown option '%s'" % (test_list, line_number, arg)) >+ else: >+ test_name += arg >+ >+ if test_name.endswith(".txt"): >+ for r in _parse_webgl_tests(test_list_root, prefix / test_name, test_min_version, test_max_version): >+ yield r >+ else: >+ yield _WebGLTest( >+ (prefix / test_name).relative_to(test_list_root), >+ min_version, >+ max_version, >+ ) >+ >+ >+def _filter_webgl_test_paths_for_suite_version(tests: Iterable[_WebGLTest], suite_version: Version) -> Generator[Path, None, None]: >+ for test in tests: >+ if test.min_version <= suite_version and test.max_version >= suite_version: >+ if _use_verbose_output: >+ print(f"Using test: {test.path} {test.min_version} <= {suite_version} <= {test.max_version}") >+ yield test.path >+ else: >+ if _use_verbose_output: >+ print(f"Ignoring test: {test.path} {test.min_version} <= {suite_version} <= {test.max_version}") >+ >+ >+def _generate_webkit_webgl_tests( >+ source_tests_dir: Path, >+ source_patterns: _IgnoredFilenameMatcher, >+ suite_version: Version, >+ use_webgl2_context: bool, >+ target_tests_dir: Path, >+): >+ target_test_files_dir = target_tests_dir / "resources" / "webgl_test_files" >+ _copy_tree(source_tests_dir, target_test_files_dir, source_patterns) >+ >+ source_js_test_harness = _tool_dir / "webkit-webgl-test-harness-template.js" >+ target_js_test_harness = target_tests_dir / "resources" / "webkit-webgl-test-harness.js" >+ target_js_test_harness.parent.mkdir(parents=True, exist_ok=True) >+ shutil.copyfile(source_js_test_harness, target_js_test_harness) >+ >+ test_template = (_tool_dir / "webgl-test-driver-template.html").read_text() >+ expectation_template = (_tool_dir / "webgl-expectation-template.txt").read_text() >+ >+ tests = _parse_webgl_tests(source_tests_dir, (source_tests_dir / "00_test_list.txt"), suite_version, suite_version) >+ >+ for test_path in _filter_webgl_test_paths_for_suite_version(tests, suite_version): >+ target_test = target_tests_dir / test_path >+ target_test_impl = target_test_files_dir / test_path >+ if not target_test_impl.exists(): >+ if _use_verbose_output: >+ print(f"Ignoring test: {test_path}, implementation does not exist at {target_test_impl}") >+ continue >+ test_to_impl = os.path.relpath(target_test_impl, target_test.parent) >+ test_url = f"{test_to_impl}?webglVersion=2" if use_webgl2_context else test_to_impl >+ subs = {"url": test_url, "url_name": test_path.name, "base_url": os.path.relpath(target_tests_dir, target_test.parent)} >+ target_test.parent.mkdir(parents=True, exist_ok=True) >+ target_test.write_text(test_template % subs) >+ print(f"wrote {target_test}") >+ expectation = target_test.parent / f"{target_test.stem}-expected.txt" >+ expectation.write_text(expectation_template % subs) >+ >+ >+def _find_expectations_for_removed_tests(layout_tests_dir: Path): >+ test_prefixes = set() >+ expectations = set() >+ for root, _, files in os.walk(layout_tests_dir): >+ for file_name in files: >+ relative_path = (Path(root) / file_name).relative_to(layout_tests_dir) >+ if relative_path.stem.endswith("-expected"): >+ expectations.add(relative_path) >+ else: >+ test_prefixes.add(relative_path.parent / relative_path.stem) >+ old_expectations = set([]) >+ for expectation in expectations: >+ test_path = expectation.parent >+ while len(test_path.parts) >= 1: >+ test_prefix = test_path / expectation.stem[: -len("-expected")] >+ if test_prefix in test_prefixes: >+ break >+ test_path = Path("/".join(test_path.parts[1:])) >+ if len(test_path.parts) < 1: >+ old_expectations.add(expectation) >+ return old_expectations >+ >+ >+def main(): >+ parser = argparse.ArgumentParser() >+ parser.add_argument("-v", "--verbose", action="store_true", help="print verbose output.") >+ parser.add_argument("webgl_repository", help="path to WebGL conformance test repository root.") >+ parser.add_argument( >+ "-l", >+ "--layout-tests-dir", >+ help="base directory for searching for platform specific tests. Defaults to LayoutTests.", >+ default=_layout_tests_dir, >+ ) >+ >+ options = parser.parse_args() >+ global _use_verbose_output >+ _use_verbose_output = options.verbose or False >+ source_dir = Path(options.webgl_repository) >+ target_dir = Path(options.layout_tests_dir) / "webgl" >+ >+ _generate_webkit_webgl_tests( >+ source_tests_dir=source_dir / "conformance-suites" / "1.0.3", >+ source_patterns=_conformance_patterns, >+ suite_version=Version("1.0.3"), >+ use_webgl2_context=False, >+ target_tests_dir=target_dir / "1.0.3", >+ ) >+ _generate_webkit_webgl_tests( >+ source_tests_dir=source_dir / "conformance-suites" / "2.0.0", >+ source_patterns=_conformance_patterns, >+ suite_version=Version("2.0.1"), >+ use_webgl2_context=True, >+ target_tests_dir=target_dir / "2.0.0", >+ ) >+ _generate_webkit_webgl_tests( >+ source_tests_dir=source_dir / "sdk" / "tests", >+ source_patterns=_sdk_patterns, >+ suite_version=Version("2.0.1"), >+ use_webgl2_context=True, >+ target_tests_dir=target_dir / "sdk", >+ ) >+ layout_tests_dir = Path(options.layout_tests_dir) >+ >+ old_expectations = _find_expectations_for_removed_tests(layout_tests_dir) >+ old_expectations = [e for e in old_expectations if "webgl" in str(e)] >+ if old_expectations: >+ print( >+ "Old expectations maybe found. Maybe do:\n git rm " >+ + " ".join(sorted([str((layout_tests_dir / e).relative_to(layout_tests_dir.parent)) for e in old_expectations])) >+ ) >+ >+ >+if __name__ == "__main__": >+ sys.exit(main()) >diff --git a/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/webgl-expectation-template.txt b/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/webgl-expectation-template.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..237e8b388e0c09338186a4b0da184d2213770f09 >--- /dev/null >+++ b/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/webgl-expectation-template.txt >@@ -0,0 +1,4 @@ >+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL. >+ >+Test: %(url)s >+[ PASS ] All tests passed >diff --git a/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/webgl-test-driver-template.html b/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/webgl-test-driver-template.html >new file mode 100644 >index 0000000000000000000000000000000000000000..513f8ca4ce696eb4f1692939bc2919d2271d3a18 >--- /dev/null >+++ b/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/webgl-test-driver-template.html >@@ -0,0 +1,18 @@ >+<!-- This file is auto-generated by Tools/Scripts/update-webgl-conformance-tests. DO NOT EDIT --> >+<!DOCTYPE html> >+<html> >+<head> >+<meta charset="utf-8"> >+<title>WebGL Conformance Test Wrapper for %(url_name)s</title> >+<script type="text/javascript" src="%(base_url)s/../resources/js-test-pre.js"></script> >+<script type="text/javascript" src="%(base_url)s/resources/webkit-webgl-test-harness.js"></script> >+</head> >+<body> >+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p> >+Test: <a href="%(url)s">%(url)s</a> >+<div id="iframe"> >+<iframe src="%(url)s" width="800" height="600"></iframe> >+</div> >+<div id="result"></div> >+</body> >+</html> >diff --git a/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/webkit-webgl-test-harness-template.js b/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/webkit-webgl-test-harness-template.js >new file mode 100644 >index 0000000000000000000000000000000000000000..c8615be500ab7e9689d23eefeec1cfc6c409402e >--- /dev/null >+++ b/Tools/Scripts/webkitpy/update_webgl_conformance_tests_lib/webkit-webgl-test-harness-template.js >@@ -0,0 +1,77 @@ >+"use strict"; >+(function() { >+ var numFailures = 0; >+ var resultsList = null; >+ var resultNum = 1; >+ >+ if (window.testRunner && !window.layoutTestController) { >+ window.layoutTestController = window.testRunner; >+ } >+ >+ if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+ >+ // Turn off console messages because for the WebGL tests they are >+ // GPU capability dependent. >+ window.console.log = function() { }; >+ window.console.error = function() { }; >+ } >+ >+ >+ if (window.internals) { >+ window.internals.settings.setWebGLErrorsToConsoleEnabled(false); >+ } >+ >+ var list = function(msg, color) { >+ if (!resultsList) { >+ resultsList = document.createElement("ul"); >+ document.getElementById("result").appendChild(resultsList); >+ } >+ >+ var item = document.createElement("li"); >+ item.appendChild(document.createTextNode(msg)); >+ if (color) { >+ item.style.color = color; >+ } >+ >+ resultsList.appendChild(item); >+ } >+ >+ var log = function(msg, color) { >+ var div = document.createElement("div"); >+ div.appendChild(document.createTextNode(msg)); >+ if (color) { >+ div.style.color = color; >+ } >+ document.getElementById("result").appendChild(div); >+ }; >+ >+ window.webglTestHarness = { >+ reportResults: function(url, success, msg) { >+ if (success) { >+ list(`[ ${resultNum}: PASS ] ${msg}`, "green"); >+ } else { >+ list(`[ ${resultNum}: FAIL ] ${msg}`, "red"); >+ ++numFailures; >+ } >+ >+ ++resultNum; >+ }, >+ >+ notifyFinished: function(url) { >+ var iframe = document.getElementById("iframe"); >+ if (numFailures > 0) { >+ log(`[ FAIL ] ${numFailures} failures reported`, "red"); >+ } else { >+ resultsList.innerHTML = ""; >+ iframe.innerHTML = ""; >+ log("[ PASS ] All tests passed", "green"); >+ } >+ >+ if (window.layoutTestController) { >+ layoutTestController.notifyDone(); >+ } >+ }, >+ } >+}()); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 476b676f0bada42f294e484c02e6e87e84941e22..d242d9afa6bf4088b3b81c8c31c463d8d7a0ba49 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2021-03-12 Kimmo Kinnunen <kkinnunen@apple.com> >+ >+ Make WebGL conformance test update script more usable and consistent >+ https://bugs.webkit.org/show_bug.cgi?id=223112 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Move the script over the existing but unused Tools/Scripts/update-webgl-conformance-tests. >+ >+ * webgl/generate-webgl-tests: Removed. >+ > 2021-03-11 Rob Buis <rbuis@igalia.com> > > Apply transferred min/max sizes for intrinsic sizing >diff --git a/LayoutTests/webgl/generate-webgl-tests b/LayoutTests/webgl/generate-webgl-tests >deleted file mode 100755 >index 5a95f20672de56dc9b0ade40f7c8d4313959880f..0000000000000000000000000000000000000000 >--- a/LayoutTests/webgl/generate-webgl-tests >+++ /dev/null >@@ -1,270 +0,0 @@ >-#!/usr/bin/env python3 >-# Copyright (C) 2013 Google Inc. All rights reserved. >-# >-# Redistribution and use in source and binary forms, with or without >-# modification, are permitted provided that the following conditions are >-# met: >-# >-# * Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# * Redistributions in binary form must reproduce the above >-# copyright notice, this list of conditions and the following disclaimer >-# in the documentation and/or other materials provided with the >-# distribution. >-# * Neither the name of Google Inc. nor the names of its >-# contributors may be used to endorse or promote products derived from >-# this software without specific prior written permission. >-# >-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- >-"""generates webgl layout tests from the Khronos WebGL Conformance Tests""" >- >-# To use this, get a copy of the WebGL conformance tests then run this script >-# eg. >-# >-# cd ~/temp >-# git clone git://github.com/KhronosGroup/WebGL.git >-# cd ~/WebKit/LayoutTests/webgl >-# python generate-webgl-tests.py -w ~/temp/WebGL/sdk/tests -e >-# >-# Now check run the LayoutTests, update TestExpectations and check in the >-# result. >- >-import copy >-import os >-import os.path >-import sys >-import re >-import json >-import shutil >-from optparse import OptionParser >- >-if sys.version < '2.6': >- print 'Wrong Python Version !!!: Need >= 2.6' >- sys.exit(1) >- >- >-GLOBAL_OPTIONS = { >- # version use. Tests at or below this will be included. >- "version": "2.0.0", >- >- # version used for unlabled tests >- "default-version": "2.0", >- >- # If set, the version we require. Tests below this will be ignored. >- "min-version": "1.0.3", >-} >- >- >-def ReadFile(filename): >- """Reads a file as a string""" >- file = open(filename, "r") >- data = file.read() >- file.close() >- return data >- >- >-def WriteFile(filename, data): >- """Writes a string as a file""" >- print "Writing: ", filename >- dirname = os.path.dirname(filename) >- if not os.path.exists(dirname): >- os.makedirs(dirname) >- file = open(filename, "wb") >- file.write(data) >- file.close() >- >- >-def CopyTree(src, dst, ignore=None): >- """Recursively copy a directory tree""" >- names = os.listdir(src) >- if ignore is not None: >- ignored_names = ignore(src, names) >- else: >- ignored_names = set() >- >- if not os.path.exists(dst): >- os.makedirs(dst) >- errors = [] >- for name in names: >- if name in ignored_names: >- continue >- srcname = os.path.join(src, name) >- dstname = os.path.join(dst, name) >- try: >- if os.path.isdir(srcname): >- CopyTree(srcname, dstname, ignore) >- else: >- # Will raise a SpecialFileError for unsupported file types >- shutil.copyfile(srcname, dstname) >- # catch the Error from the recursive copytree so that we can >- # continue with other files >- except Error, err: >- errors.extend(err.args[0]) >- except EnvironmentError, why: >- errors.append((srcname, dstname, str(why))) >- if errors: >- raise Error, errors >- >- >-def FileReader(filename): >- """A File generator that returns only non empty, non comment lines""" >- file = open(filename, "r") >- lines = file.readlines() >- file.close() >- for line_number, line in enumerate(lines): >- line = line.strip() >- if (len(line) > 0 and >- not line.startswith("#") and >- not line.startswith(";") and >- not line.startswith("//")): >- yield line_number + 1, line >- >- >-def GreaterThanOrEqualToVersion(have, want): >- """Compares to version strings""" >- have = have.split(" ")[0].split(".") >- want = want.split(" ")[0].split(".") >- for ndx, want_str in enumerate(want): >- want_num = int(want_str) >- have_num = 0 >- if ndx < len(have): >- have_num = int(have[ndx]) >- if have_num < want_num: >- return False >- if have_num >= want_num: >- return True >- return True >- >- >-def GetTestList(list_filename, dest_dir, hierarchical_options): >- global GLOBAL_OPTIONS >- tests = [] >- prefix = os.path.dirname(list_filename) >- for line_number, line in FileReader(list_filename): >- args = line.split() >- test_options = {} >- non_options = [] >- use_test = True >- while len(args): >- arg = args.pop(0) >- if arg.startswith("-"): >- if not arg.startswith("--"): >- raise "%s:%d bad option" % (list_filename, line_number) >- option = arg[2:] >- if option == 'slow': >- pass >- elif option == 'min-version' or option == "max-version": >- test_options[option] = args.pop(0) >- else: >- raise Exception("%s:%d unknown option '%s'" % (list_filename, line_number, arg)) >- else: >- non_options.append(arg) >- url = os.path.join(prefix, " ".join(non_options)) >- >- if not url.endswith(".txt"): >- if "min-version" in test_options: >- min_version = test_options["min-version"] >- else: >- min_version = hierarchical_options["default-version"] >- >- if "min-version" in GLOBAL_OPTIONS: >- use_test = GreaterThanOrEqualToVersion(min_version, GLOBAL_OPTIONS["min-version"]) >- else: >- use_test = GreaterThanOrEqualToVersion(GLOBAL_OPTIONS["version"], min_version) >- >- if not use_test: >- continue >- >- if url.endswith(".txt"): >- if "min-version" in test_options: >- hierarchical_options["default-version"] = test_options["min-version"] >- tests = tests + GetTestList( >- os.path.join(prefix, url), dest_dir, copy.copy(hierarchical_options)) >- else: >- tests.append({"url": url}) >- return tests >- >- >-def main(argv): >- """This is the main function.""" >- global GLOBAL_OPTIONS >- >- parser = OptionParser() >- parser.add_option( >- "-v", "--verbose", action="store_true", >- help="prints more output.") >- parser.add_option( >- "-w", "--webgl-conformance-test", dest="source_dir", >- help="path to webgl conformance tests. REQUIRED") >- parser.add_option( >- "-n", "--no-copy", action="store_true", >- help="do not copy tests") >- parser.add_option( >- "-e", "--generate-expectations", action="store_true", >- help="generatet the test expectations") >- parser.add_option( >- "-o", "--output-dir", dest="output_dir", >- help="base directory for output. defaults to \'.\'", >- default=".") >- >- (options, args) = parser.parse_args(args=argv) >- >- if not options.source_dir: >- parser.print_help() >- return 1 >- >- os.chdir(os.path.dirname(__file__) or '.') >- >- source_dir = options.source_dir; >- output_dir = options.output_dir; >- webgl_tests_dir = os.path.join(output_dir, "resources/webgl_test_files") >- >- # copy all the files from the WebGL conformance tests. >- if not options.no_copy: >- CopyTree( >- source_dir, webgl_tests_dir, shutil.ignore_patterns( >- '.git', '*.pyc', 'tmp*')) >- >- test_template = ReadFile("resources/webgl-wrapper-template.html") >- expectation_template = ReadFile("resources/webgl-expectation-template.txt") >- >- # generate wrappers for all the tests >- tests = GetTestList(os.path.join(source_dir, "00_test_list.txt"), ".", >- copy.copy(GLOBAL_OPTIONS)) >- >- for test in tests: >- url = os.path.relpath(test["url"], source_dir) >- dst = os.path.join(output_dir, url) >- dst_dir = os.path.dirname(dst) >- src = os.path.relpath(os.path.join(webgl_tests_dir, url), dst_dir).replace("\\", "/") >- base_url = os.path.relpath(output_dir, dst_dir).replace("\\", "/") >- subs = { >- "url": src, >- "url_name": os.path.basename(url), >- "base_url": base_url, >- } >- WriteFile(dst, test_template % subs) >- if options.generate_expectations: >- expectation_filename = os.path.splitext(dst)[0] + "-expected.txt" >- WriteFile(expectation_filename, expectation_template % subs) >- >- >- >-if __name__ == '__main__': >- sys.exit(main(sys.argv[1:])) >- >- >- >- >- >diff --git a/LayoutTests/webgl/resources/webgl-expectation-template.txt b/LayoutTests/webgl/resources/webgl-expectation-template.txt >deleted file mode 100644 >index e6fb73cd4f69b7d6d2b7d10e4f46a5ef130381bb..0000000000000000000000000000000000000000 >--- a/LayoutTests/webgl/resources/webgl-expectation-template.txt >+++ /dev/null >@@ -1,5 +0,0 @@ >-This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL. >- >-Test: %(url)s >-[ PASS ] All tests passed >- >diff --git a/LayoutTests/webgl/resources/webgl-wrapper-template.html b/LayoutTests/webgl/resources/webgl-wrapper-template.html >deleted file mode 100644 >index f1c8379bd18e877ce6f23a69d906892c62b167c1..0000000000000000000000000000000000000000 >--- a/LayoutTests/webgl/resources/webgl-wrapper-template.html >+++ /dev/null >@@ -1,18 +0,0 @@ >-<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT --> >-<!DOCTYPE html> >-<html> >-<head> >-<meta charset="utf-8"> >-<title>WebGL Conformance Test Wrapper for %(url_name)s</title> >-<script type="text/javascript" src="%(base_url)s/../resources/js-test-pre.js"></script> >-<script type="text/javascript" src="%(base_url)s/resources/webkit-webgl-test-harness.js"></script> >-</head> >-<body> >-<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p> >-Test: <a href="%(url)s">%(url)s</a> >-<div id="iframe"> >-<iframe src="%(url)s" width="800" height="600"></iframe> >-</div> >-<div id="result"></div> >-</body> >-</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 223112
:
423020
|
423021
|
423379