summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webgl/tools
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/webgl/tools
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/webgl/tools')
-rwxr-xr-xtesting/web-platform/tests/webgl/tools/import-conformance-tests.py141
-rw-r--r--testing/web-platform/tests/webgl/tools/js-test-pre.patch84
-rw-r--r--testing/web-platform/tests/webgl/tools/unit.patch17
3 files changed, 242 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webgl/tools/import-conformance-tests.py b/testing/web-platform/tests/webgl/tools/import-conformance-tests.py
new file mode 100755
index 000000000..e4fb16f6a
--- /dev/null
+++ b/testing/web-platform/tests/webgl/tools/import-conformance-tests.py
@@ -0,0 +1,141 @@
+#!/usr/bin/env python
+
+import os
+import subprocess
+import sys
+import tempfile
+import shutil
+import bisect
+import argparse
+
+KHRONOS_REPO_URL = "https://github.com/KhronosGroup/WebGL.git"
+PATCHES = [
+ ("js-test-pre.patch", "resources/js-test-pre.js"),
+ ("unit.patch", "conformance/more/unit.js")
+]
+
+def usage():
+ print("Usage: {} version destination [existing_webgl_repo]".format(sys.argv[0]))
+ sys.exit(1)
+
+def get_tests(base_dir, file_name, tests_list):
+ list_file = os.path.join(base_dir, file_name)
+ if not os.path.isfile(list_file):
+ print("Test list ({}) not found".format(list_file))
+ sys.exit(1)
+
+ print("Processing: {}".format(list_file))
+
+ with open(list_file, "r") as f:
+ for line in f:
+ line = line.strip()
+ if not line or line.startswith("#") or line.startswith("//"):
+ continue # It's an empty line or a comment
+
+ # Lines often are in the form:
+ # --min-version x.x.x abc.html
+ #
+ # We only care about the last part
+ line = line.split(" ")[-1]
+
+ if line.endswith(".html"):
+ tests_list.append(os.path.join(base_dir, line))
+ if line.endswith(".txt"):
+ (next_dir, file_name) = os.path.split(os.path.join(base_dir, line))
+ get_tests(next_dir, file_name, tests_list)
+
+
+# Insert the test harness scripts before any other script
+def process_test(test):
+ (new, new_path) = tempfile.mkstemp()
+ script_tag_found = False
+ with open(test, "r") as test_file:
+ for line in test_file:
+ if not script_tag_found and "<script" in line:
+ indent = ' ' * line.index('<')
+ script_tag_found = True
+ os.write(new, "{}<script src=/resources/testharness.js></script>\n".format(indent))
+ os.write(new, "{}<script src=/resources/testharnessreport.js></script>\n".format(indent))
+ os.write(new, line)
+
+ os.close(new)
+ shutil.move(new_path, test)
+
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("version", help="WebGL test suite version (e.g.: 1.0.3)")
+ parser.add_argument("destination", help="Test suite destination")
+ parser.add_argument("-e", "--existing-repo", help="Path to an existing clone of the khronos WebGL repository")
+ args = parser.parse_args()
+
+ version = args.version
+ destination = args.destination
+
+ print("Trying to import WebGL conformance test suite {} into {}".format(version, destination))
+
+ if args.existing_repo:
+ directory = args.existing_repo
+ print("Using existing WebGL repository: {}".format(directory))
+ else:
+ directory = tempfile.mkdtemp()
+ print("Cloning WebGL repository into temporary directory {}".format(directory))
+ subprocess.check_call(["git", "clone", KHRONOS_REPO_URL, directory, "--depth", "1"])
+
+ suite_dir = os.path.join(directory, "conformance-suites", version)
+ print("Test suite directory: {}".format(suite_dir))
+
+ if not os.path.isdir(suite_dir):
+ print("Test suite directory ({}) not found, aborting...".format(suite_dir))
+ sys.exit(1)
+
+ # We recursively copy all the test suite to `destination`
+ shutil.copytree(suite_dir, destination)
+
+ # Get all the tests, remove any html file which is not in the list, and
+ # later process them.
+ tests = []
+ get_tests(destination, "00_test_list.txt", tests)
+
+ test_count = len(tests)
+
+ print("Found {} tests.".format(test_count))
+ print("Removing non-test html files")
+
+ # To use binary search, which speeds things up a little
+ # instead of f in tests
+ tests.sort()
+
+ # Remove html files that are not tests
+ for dirpath, dirnames, filenames in os.walk(destination):
+ if '/resources' in dirpath:
+ continue # Most of the files under resources directories are used
+
+ for f in filenames:
+ if not f.endswith('.html'):
+ continue
+
+ f = os.path.join(dirpath, f)
+ pos = bisect.bisect_left(tests, f)
+ if pos == test_count or tests[pos] != f:
+ print("Removing: {}".format(f))
+ os.remove(f)
+
+ # Insert our harness into the tests
+ for test in tests:
+ process_test(test)
+
+ # Try to apply the patches to the required files
+
+ this_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
+ for patch, file_name in PATCHES:
+ try:
+ patch = os.path.join(this_dir, patch)
+ subprocess.check_call(["patch", "-d", destination, file_name, patch])
+ except subprocess.CalledProcessError:
+ print("Automatic patch failed for {}".format(file_name))
+ print("Please review the WPT integration and update {} accordingly".format(os.path.basename(patch)))
+
+if __name__ == '__main__':
+ main()
diff --git a/testing/web-platform/tests/webgl/tools/js-test-pre.patch b/testing/web-platform/tests/webgl/tools/js-test-pre.patch
new file mode 100644
index 000000000..1e8a4c958
--- /dev/null
+++ b/testing/web-platform/tests/webgl/tools/js-test-pre.patch
@@ -0,0 +1,84 @@
+--- js-test-pre.orig.js 2016-04-08 22:35:15.629226767 +0200
++++ js-test-pre.js 2016-04-08 22:43:11.906092062 +0200
+@@ -71,11 +71,25 @@
+ }
+ }
+
+-function reportTestResultsToHarness(success, msg) {
+- if (window.parent.webglTestHarness) {
+- window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
++(function() {
++ var WPT_TEST_ID = 0;
++
++ // Store the current WPT test harness `test` function
++ // if found, since it's overriden by some tests.
++ var wpt_test = window.test;
++ var wpt_assert_true = window.assert_true;
++
++
++ window.reportTestResultsToHarness = function reportTestResultsToHarness(success, msg) {
++ if (window.parent.webglTestHarness) {
++ window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
++ } else if (wpt_test) { // WPT test harness
++ wpt_test(function () {
++ wpt_assert_true(success, msg);
++ }, "WebGL test #" + (WPT_TEST_ID++) + ": " + msg);
++ }
+ }
+-}
++}())
+
+ function notifyFinishedToHarness() {
+ if (window.parent.webglTestHarness) {
+@@ -92,7 +106,7 @@
+ window.console.log(msg);
+ }
+
+-var _jsTestPreVerboseLogging = false;
++var _jsTestPreVerboseLogging = true;
+
+ function enableJSTestPreVerboseLogging()
+ {
+@@ -105,31 +119,18 @@
+ if (msg === undefined) {
+ msg = document.title;
+ }
+- // For MSIE 6 compatibility
+- var span = document.createElement("span");
+- span.innerHTML = '<p>' + msg + '</p><p>On success, you will see a series of "<span class="pass">PASS</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
+- var description = document.getElementById("description");
+- if (description.firstChild)
+- description.replaceChild(span, description.firstChild);
+- else
+- description.appendChild(span);
+- if (_jsTestPreVerboseLogging) {
+- _logToConsole(msg);
+- }
++ _logToConsole("DESCRIPTION: " + msg);
+ }
+
+ function _addSpan(contents)
+ {
+- var span = document.createElement("span");
+- document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace
+- span.innerHTML = contents + '<br />';
+ }
+
+ function debug(msg)
+ {
+ _addSpan(msg);
+ if (_jsTestPreVerboseLogging) {
+- _logToConsole(msg);
++ _logToConsole(msg);
+ }
+ }
+
+@@ -143,7 +144,7 @@
+ reportTestResultsToHarness(true, msg);
+ _addSpan('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
+ if (_jsTestPreVerboseLogging) {
+- _logToConsole('PASS ' + msg);
++ _logToConsole('PASS ' + msg);
+ }
+ }
+
diff --git a/testing/web-platform/tests/webgl/tools/unit.patch b/testing/web-platform/tests/webgl/tools/unit.patch
new file mode 100644
index 000000000..58a242c51
--- /dev/null
+++ b/testing/web-platform/tests/webgl/tools/unit.patch
@@ -0,0 +1,17 @@
+--- conformance/more/unit.js 2015-06-18 23:26:41.085626000 +0200
++++ ../conformance-1.0.3/conformance/more/unit.js 2015-12-30 19:46:34.570636491 +0100
+@@ -892,9 +892,14 @@
+ 0x809D
+ ];
+
++var WPT_TEST_ID = 0;
+ function reportTestResultsToHarness(success, msg) {
+ if (window.parent.webglTestHarness) {
+ window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
++ } else if (window.test) { // WPT test harness
++ test(function () {
++ assert_true(success, msg);
++ }, "WebGL test #" + (WPT_TEST_ID++) + ": " + msg);
+ }
+ }
+