author | Jeff Gilbert <jgilbert@mozilla.com> |
Mon, 02 Apr 2018 18:07:01 -0700 | |
changeset 468442 | 29419d3ec2915214734a505fbb6de31acc8c9fe5 |
parent 468441 | e2da4a4bac5c9cdcbae8cb9bd08c08fd407cec87 |
child 468443 | 40c9812744cf8ddacb15e2ad7e46e39c4c2d2fa4 |
push id | 9165 |
push user | asasaki@mozilla.com |
push date | Thu, 26 Apr 2018 21:04:54 +0000 |
treeherder | mozilla-beta@064c3804de2e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | kvark |
bugs | 1450839 |
milestone | 61.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/canvas/test/webgl-conf/generate-wrappers-and-manifest.py | file | annotate | diff | comparison | revisions | |
dom/canvas/test/webgl-conf/import.py | file | annotate | diff | comparison | revisions |
--- a/dom/canvas/test/webgl-conf/generate-wrappers-and-manifest.py +++ b/dom/canvas/test/webgl-conf/generate-wrappers-and-manifest.py @@ -1,18 +1,19 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # Write a Mochitest manifest for WebGL conformance test files. import os import re +from pathlib import * # All paths in this file are based where this file is run. WRAPPER_TEMPLATE_FILE = 'mochi-wrapper.html.template' MANIFEST_TEMPLATE_FILE = 'mochitest.ini.template' ERRATA_FILE = 'mochitest-errata.ini' DEST_MANIFEST_PATHSTR = 'generated-mochitest.ini' BASE_TEST_LIST_PATHSTR = 'checkout/00_test_list.txt' @@ -92,17 +93,17 @@ class TestEntry: def AccumTests(pathStr, listFile, allowWebGL1, allowWebGL2, out_testList): listPathStr = pathStr + '/' + listFile listPath = listPathStr.replace('/', os.sep) assert os.path.exists(listPath), 'Bad `listPath`: ' + listPath - with open(listPath, 'rb') as fIn: + with open(listPath, 'r') as fIn: lineNum = 0 for line in fIn: lineNum += 1 line = line.rstrip() if not line: continue @@ -165,24 +166,24 @@ def AccumTests(pathStr, listFile, allowW def FillTemplate(inFilePath, templateDict, outFilePath): templateShell = ImportTemplate(inFilePath) OutputFilledTemplate(templateShell, templateDict, outFilePath) return def ImportTemplate(inFilePath): - with open(inFilePath, 'rb') as f: + with open(inFilePath, 'r') as f: return TemplateShell(f) def OutputFilledTemplate(templateShell, templateDict, outFilePath): spanStrList = templateShell.Fill(templateDict) - with open(outFilePath, 'wb') as f: + with open(outFilePath, 'w', newline='\n') as f: f.writelines(spanStrList) return ############################## # Internals def WrapWithIndent(lines, indentLen): split = lines.split('\n') @@ -345,17 +346,17 @@ kManifestRelPathStr = kManifestRelPathSt def ManifestPathStr(pathStr): pathStr = kManifestRelPathStr + '/' + pathStr return os.path.normpath(pathStr).replace(os.sep, '/') def WriteManifest(wrapperPathStrList, supportPathStrList): destPathStr = DEST_MANIFEST_PATHSTR - print 'Generating manifest: ' + destPathStr + print('Generating manifest: ' + destPathStr) errataMap = LoadErrata() # DEFAULT_ERRATA defaultSectionName = 'DEFAULT' defaultSectionLines = [] if defaultSectionName in errataMap: @@ -368,17 +369,17 @@ def WriteManifest(wrapperPathStrList, su supportPathStrList = [ManifestPathStr(x) for x in supportPathStrList] supportPathStrList = sorted(supportPathStrList) supportFilesStr = '\n'.join(supportPathStrList) # MANIFEST_TESTS manifestTestLineList = [] wrapperPathStrList = sorted(wrapperPathStrList) for wrapperPathStr in wrapperPathStrList: - #print 'wrapperPathStr: ' + wrapperPathStr + #print('wrapperPathStr: ' + wrapperPathStr) wrapperManifestPathStr = ManifestPathStr(wrapperPathStr) sectionName = '[' + wrapperManifestPathStr + ']' manifestTestLineList.append(sectionName) errataLines = [] if wrapperPathStr in errataMap: errataLines = errataMap[wrapperPathStr] @@ -394,19 +395,19 @@ def WriteManifest(wrapperPathStrList, su if needsSkip: errataLines.append('skip-if = ' + WEBGL2_SKIP_IF_CONDITION) manifestTestLineList += errataLines continue if errataMap: - print 'Errata left in map:' + print('Errata left in map:') for x in errataMap.keys(): - print ' '*4 + x + print(' '*4 + x) assert False manifestTestsStr = '\n'.join(manifestTestLineList) # Fill the template. templateDict = { 'DEFAULT_ERRATA': defaultSectionStr, 'SUPPORT_FILES': supportFilesStr, @@ -426,17 +427,17 @@ def LoadINI(path): curSectionName = None curSectionMap = {} lineNum = 0 ret = {} ret[curSectionName] = (lineNum, curSectionMap) - with open(path, 'rb') as f: + with open(path, 'r') as f: for line in f: lineNum += 1 line = line.strip() if not line: continue if line[0] in [';', '#']: @@ -464,26 +465,26 @@ def LoadINI(path): return ret def LoadErrata(): iniMap = LoadINI(ERRATA_FILE) ret = {} - for (sectionName, (sectionLineNum, sectionMap)) in iniMap.iteritems(): + for (sectionName, (sectionLineNum, sectionMap)) in iniMap.items(): curLines = [] if sectionName == None: continue elif sectionName != 'DEFAULT': path = sectionName.replace('/', os.sep) assert os.path.exists(path), 'Errata line {}: Invalid file: {}'.format(sectionLineNum, sectionName) - for (key, (lineNum, val)) in sectionMap.iteritems(): + for (key, (lineNum, val)) in sectionMap.items(): assert key in ACCEPTABLE_ERRATA_KEYS, 'Line {}: {}'.format(lineNum, key) curLine = '{} = {}'.format(key, val) curLines.append(curLine) continue ret[sectionName] = curLines continue @@ -514,18 +515,19 @@ def GetFilePathListForDir(baseDir): filePath = os.path.join(root, f) filePath = filePath.replace(os.sep, '/') ret.append(filePath) return ret if __name__ == '__main__': - fileDir = os.path.dirname(__file__) - assert not fileDir, 'Run this file from its directory, not ' + fileDir + file_dir = Path(__file__).parent + cwd = Path.cwd() + assert cwd.samefile(file_dir), 'Run this file from its directory.' testEntryList = GetTestList() wrapperPathStrList = WriteWrappers(testEntryList) supportPathStrList = GetSupportFileList() WriteManifest(wrapperPathStrList, supportPathStrList) print('Done!')
new file mode 100755 --- /dev/null +++ b/dom/canvas/test/webgl-conf/import.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python3 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +assert __name__ == '__main__' + +from pathlib import * +import subprocess +import sys + +REPO_DIR = Path.cwd() +DIR_IN_GECKO = Path(__file__).parent +assert not REPO_DIR.samefile(DIR_IN_GECKO), 'Run from the KhronosGroup/WebGL checkout.' +assert DIR_IN_GECKO.as_posix().endswith('dom/canvas/test/webgl-conf') + +def print_now(*args): + print(*args) + sys.stdout.flush() + + +def run_checked(*args, **kwargs): + print_now(' ', args) + return subprocess.run(args, check=True, shell=True, **kwargs) + + +src_dir = Path(REPO_DIR, 'sdk/tests').as_posix() +dest_dir = Path(DIR_IN_GECKO, 'checkout').as_posix() +assert dest_dir.endswith('dom/canvas/test/webgl-conf/checkout') # Be paranoid with rm -rf. +run_checked("rm -rf '{}'".format(dest_dir)) +run_checked("mkdir '{}'".format(dest_dir)); +run_checked("cp -rT '{}' '{}'".format(src_dir, dest_dir)); + +print_now('Done!')