Create match command to update WebGL conformance suite from upstream

This commit is contained in:
Imanol Fernandez 2017-10-30 19:02:33 +01:00
parent 052971a71a
commit b5043de011
2 changed files with 41 additions and 15 deletions

View file

@ -20,6 +20,7 @@ from time import time
import json
import urllib2
import base64
import shutil
from mach.registrar import Registrar
from mach.decorators import (
@ -929,3 +930,24 @@ testing/web-platform/mozilla/tests for Servo-only tests""" % reference_path)
run_globals = {"__file__": run_file}
execfile(run_file, run_globals)
return run_globals["update_test_file"](cache_dir)
@Command('update-webgl',
description='Update the WebGL conformance suite tests from Khronos repo',
category='testing')
@CommandArgument('--version', action='store_true', default='1.0.3',
help='WebGL conformance suite version')
def update_webgl(self, version=None):
self.ensure_bootstrapped()
base_dir = path.abspath(path.join(PROJECT_TOPLEVEL_PATH,
"tests", "wpt", "mozilla", "tests", "webgl"))
run_file = path.join(base_dir, "tools", "import-conformance-tests.py")
dest_folder = path.join(base_dir, "conformance-%s" % version)
patches_dir = path.join(base_dir, "tools")
# Clean dest folder if exists
if os.path.exists(dest_folder):
shutil.rmtree(dest_folder)
run_globals = {"__file__": run_file}
execfile(run_file, run_globals)
return run_globals["update_conformance"](version, dest_folder, None, patches_dir)

View file

@ -14,6 +14,10 @@ PATCHES = [
("unit.patch", "conformance/more/unit.js")
]
# Fix for 'UnicodeDecodeError: 'ascii' codec can't decode byte'
reload(sys)
sys.setdefaultencoding('utf8')
def usage():
print("Usage: {} version destination [existing_webgl_repo]".format(sys.argv[0]))
sys.exit(1)
@ -63,20 +67,11 @@ def process_test(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
def update_conformance(version, destination, existing_repo, patches_dir):
print("Trying to import WebGL conformance test suite {} into {}".format(version, destination))
if args.existing_repo:
directory = args.existing_repo
if existing_repo:
directory = existing_repo
print("Using existing WebGL repository: {}".format(directory))
else:
directory = tempfile.mkdtemp()
@ -127,15 +122,24 @@ def main():
process_test(test)
# Try to apply the patches to the required files
this_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
if not patches_dir:
patches_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
for patch, file_name in PATCHES:
try:
patch = os.path.join(this_dir, patch)
patch = os.path.join(patches_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)))
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()
update_conformance(args.version, args.destination, args.existing_repo, None)
if __name__ == '__main__':
main()