Skip to content

Commit

Permalink
Create match command to update WebGL conformance suite from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Oct 31, 2017
1 parent 052971a commit b5043de
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
22 changes: 22 additions & 0 deletions python/servo/testing_commands.py
Expand Up @@ -20,6 +20,7 @@
import json import json
import urllib2 import urllib2
import base64 import base64
import shutil


from mach.registrar import Registrar from mach.registrar import Registrar
from mach.decorators import ( from mach.decorators import (
Expand Down Expand Up @@ -929,3 +930,24 @@ def update_net_cookies(self):
run_globals = {"__file__": run_file} run_globals = {"__file__": run_file}
execfile(run_file, run_globals) execfile(run_file, run_globals)
return run_globals["update_test_file"](cache_dir) 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)
34 changes: 19 additions & 15 deletions tests/wpt/mozilla/tests/webgl/tools/import-conformance-tests.py
Expand Up @@ -14,6 +14,10 @@
("unit.patch", "conformance/more/unit.js") ("unit.patch", "conformance/more/unit.js")
] ]


# Fix for 'UnicodeDecodeError: 'ascii' codec can't decode byte'
reload(sys)
sys.setdefaultencoding('utf8')

def usage(): def usage():
print("Usage: {} version destination [existing_webgl_repo]".format(sys.argv[0])) print("Usage: {} version destination [existing_webgl_repo]".format(sys.argv[0]))
sys.exit(1) sys.exit(1)
Expand Down Expand Up @@ -63,20 +67,11 @@ def process_test(test):






def main(): def update_conformance(version, destination, existing_repo, patches_dir):
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)) print("Trying to import WebGL conformance test suite {} into {}".format(version, destination))


if args.existing_repo: if existing_repo:
directory = args.existing_repo directory = existing_repo
print("Using existing WebGL repository: {}".format(directory)) print("Using existing WebGL repository: {}".format(directory))
else: else:
directory = tempfile.mkdtemp() directory = tempfile.mkdtemp()
Expand Down Expand Up @@ -127,15 +122,24 @@ def main():
process_test(test) process_test(test)


# Try to apply the patches to the required files # Try to apply the patches to the required files

if not patches_dir:
this_dir = os.path.abspath(os.path.dirname(sys.argv[0])) patches_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
for patch, file_name in PATCHES: for patch, file_name in PATCHES:
try: try:
patch = os.path.join(this_dir, patch) patch = os.path.join(patches_dir, patch)
subprocess.check_call(["patch", "-d", destination, file_name, patch]) subprocess.check_call(["patch", "-d", destination, file_name, patch])
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("Automatic patch failed for {}".format(file_name)) print("Automatic patch failed for {}".format(file_name))
print("Please review the WPT integration and update {} accordingly".format(os.path.basename(patch))) 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__': if __name__ == '__main__':
main() main()

0 comments on commit b5043de

Please sign in to comment.