зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1622680 - Make dom/canvas flake8 compliant. r=sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D88734
This commit is contained in:
Родитель
f518fc31dc
Коммит
7c1c23dbfc
1
.flake8
1
.flake8
|
@ -5,7 +5,6 @@ exclude =
|
|||
devtools/shared,
|
||||
dom/base,
|
||||
dom/bindings,
|
||||
dom/canvas,
|
||||
dom/encoding,
|
||||
dom/websocket,
|
||||
gfx/tests,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# Write a Mochitest manifest for WebGL conformance test files.
|
||||
|
||||
import os
|
||||
from pathlib import *
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
|
||||
|
@ -37,6 +37,7 @@ ACCEPTABLE_ERRATA_KEYS = set([
|
|||
'skip-if',
|
||||
])
|
||||
|
||||
|
||||
def ChooseSubsuite(name):
|
||||
# name: generated/test_2_conformance2__vertex_arrays__vertex-array-object.html
|
||||
|
||||
|
@ -66,6 +67,7 @@ def ChooseSubsuite(name):
|
|||
########################################################################
|
||||
# GetTestList
|
||||
|
||||
|
||||
def GetTestList():
|
||||
split = BASE_TEST_LIST_PATHSTR.rsplit('/', 1)
|
||||
basePath = '.'
|
||||
|
@ -88,6 +90,7 @@ def GetTestList():
|
|||
##############################
|
||||
# Internals
|
||||
|
||||
|
||||
def IsVersionLess(a, b):
|
||||
aSplit = [int(x) for x in a.split('.')]
|
||||
bSplit = [int(x) for x in b.split('.')]
|
||||
|
@ -109,6 +112,7 @@ def IsVersionLess(a, b):
|
|||
|
||||
return False
|
||||
|
||||
|
||||
class TestEntry:
|
||||
def __init__(self, path, webgl1, webgl2):
|
||||
self.path = path
|
||||
|
@ -140,11 +144,11 @@ def AccumTests(pathStr, listFile, allowWebGL1, allowWebGL2, out_testList):
|
|||
|
||||
webgl1 = allowWebGL1
|
||||
webgl2 = allowWebGL2
|
||||
while curLine.startswith('--'): # '--min-version 1.0.2 foo.html'
|
||||
while curLine.startswith('--'): # '--min-version 1.0.2 foo.html'
|
||||
(flag, curLine) = curLine.split(' ', 1)
|
||||
if flag == '--min-version':
|
||||
(minVersion, curLine) = curLine.split(' ', 1)
|
||||
if not IsVersionLess(minVersion, "2.0.0"): # >= 2.0.0
|
||||
if not IsVersionLess(minVersion, "2.0.0"): # >= 2.0.0
|
||||
webgl1 = False
|
||||
break
|
||||
elif flag == '--max-version':
|
||||
|
@ -153,7 +157,7 @@ def AccumTests(pathStr, listFile, allowWebGL1, allowWebGL2, out_testList):
|
|||
webgl2 = False
|
||||
break
|
||||
elif flag == '--slow':
|
||||
continue # TODO
|
||||
continue # TODO
|
||||
else:
|
||||
text = 'Unknown flag \'{}\': {}:{}: {}'.format(flag, listPath,
|
||||
lineNum, line)
|
||||
|
@ -189,6 +193,7 @@ def AccumTests(pathStr, listFile, allowWebGL1, allowWebGL2, out_testList):
|
|||
########################################################################
|
||||
# Templates
|
||||
|
||||
|
||||
def FillTemplate(inFilePath, templateDict, outFilePath):
|
||||
templateShell = ImportTemplate(inFilePath)
|
||||
OutputFilledTemplate(templateShell, templateDict, outFilePath)
|
||||
|
@ -210,17 +215,18 @@ def OutputFilledTemplate(templateShell, templateDict, outFilePath):
|
|||
##############################
|
||||
# Internals
|
||||
|
||||
|
||||
def WrapWithIndent(lines, indentLen):
|
||||
split = lines.split('\n')
|
||||
if len(split) == 1:
|
||||
return lines
|
||||
split = lines.split('\n')
|
||||
if len(split) == 1:
|
||||
return lines
|
||||
|
||||
ret = [split[0]]
|
||||
indentSpaces = ' ' * indentLen
|
||||
for line in split[1:]:
|
||||
ret.append(indentSpaces + line)
|
||||
ret = [split[0]]
|
||||
indentSpaces = ' ' * indentLen
|
||||
for line in split[1:]:
|
||||
ret.append(indentSpaces + line)
|
||||
|
||||
return '\n'.join(ret)
|
||||
return '\n'.join(ret)
|
||||
|
||||
|
||||
templateRE = re.compile('(%%.*?%%)')
|
||||
|
@ -238,7 +244,6 @@ class TemplateShellSpan:
|
|||
|
||||
return
|
||||
|
||||
|
||||
def Fill(self, templateDict, indentLen):
|
||||
if self.isLiteralSpan:
|
||||
return self.span
|
||||
|
@ -284,8 +289,8 @@ class TemplateShell:
|
|||
self.spanList = spanList
|
||||
return
|
||||
|
||||
|
||||
# Returns spanStrList.
|
||||
|
||||
def Fill(self, templateDict):
|
||||
indentLen = 0
|
||||
ret = []
|
||||
|
@ -310,6 +315,7 @@ class TemplateShell:
|
|||
########################################################################
|
||||
# Output
|
||||
|
||||
|
||||
def IsWrapperWebGL2(wrapperPath):
|
||||
return wrapperPath.startswith(GENERATED_PATHSTR + '/test_' + WEBGL2_TEST_MANGLE)
|
||||
|
||||
|
@ -369,6 +375,7 @@ def WriteWrappers(testEntryList):
|
|||
kManifestRelPathStr = os.path.relpath('.', os.path.dirname(DEST_MANIFEST_PATHSTR))
|
||||
kManifestRelPathStr = kManifestRelPathStr.replace(os.sep, '/')
|
||||
|
||||
|
||||
def ManifestPathStr(pathStr):
|
||||
pathStr = kManifestRelPathStr + '/' + pathStr
|
||||
return os.path.normpath(pathStr).replace(os.sep, '/')
|
||||
|
@ -399,8 +406,6 @@ def WriteManifest(wrapperPathStrList, supportPathStrList):
|
|||
manifestTestLineList = []
|
||||
wrapperPathStrList = sorted(wrapperPathStrList)
|
||||
for wrapperPathStr in wrapperPathStrList:
|
||||
#print('wrapperPathStr: ' + wrapperPathStr)
|
||||
|
||||
wrapperManifestPathStr = ManifestPathStr(wrapperPathStr)
|
||||
sectionName = '[' + wrapperManifestPathStr + ']'
|
||||
manifestTestLineList.append(sectionName)
|
||||
|
@ -440,8 +445,10 @@ def WriteManifest(wrapperPathStrList, supportPathStrList):
|
|||
##############################
|
||||
# Internals
|
||||
|
||||
|
||||
kManifestHeaderRegex = re.compile(r'[[]([^]]*)[]]')
|
||||
|
||||
|
||||
def LoadINI(path):
|
||||
curSectionName = None
|
||||
curSectionMap = {}
|
||||
|
@ -466,7 +473,8 @@ def LoadINI(path):
|
|||
assert line[-1] == ']', '{}:{}'.format(path, lineNum)
|
||||
|
||||
curSectionName = line[1:-1]
|
||||
assert curSectionName not in ret, 'Line {}: Duplicate section: {}'.format(lineNum, line)
|
||||
assert curSectionName not in ret, 'Line {}: Duplicate section: {}'.format(
|
||||
lineNum, line)
|
||||
|
||||
curSectionMap = {}
|
||||
ret[curSectionName] = (lineNum, curSectionMap)
|
||||
|
@ -492,11 +500,12 @@ def LoadErrata():
|
|||
for (sectionName, (sectionLineNum, sectionMap)) in iniMap.items():
|
||||
curLines = []
|
||||
|
||||
if sectionName == None:
|
||||
if sectionName is None:
|
||||
continue
|
||||
elif sectionName != 'DEFAULT':
|
||||
path = sectionName.replace('/', os.sep)
|
||||
assert os.path.exists(path), 'Errata line {}: Invalid file: {}'.format(sectionLineNum, sectionName)
|
||||
assert os.path.exists(path), 'Errata line {}: Invalid file: {}'.format(
|
||||
sectionLineNum, sectionName)
|
||||
|
||||
for (key, (lineNum, val)) in sectionMap.items():
|
||||
assert key in ACCEPTABLE_ERRATA_KEYS, 'Line {}: {}'.format(lineNum, key)
|
||||
|
@ -512,6 +521,7 @@ def LoadErrata():
|
|||
|
||||
########################################################################
|
||||
|
||||
|
||||
def GetSupportFileList():
|
||||
ret = EXTRA_SUPPORT_FILES[:]
|
||||
|
||||
|
|
|
@ -6,25 +6,24 @@
|
|||
|
||||
assert __name__ == '__main__'
|
||||
|
||||
from pathlib import *
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
REL_PATH = '/dom/canvas/test/webgl-conf'
|
||||
REPO_DIR = Path.cwd()
|
||||
DIR_IN_GECKO = Path(__file__).parent
|
||||
assert not REPO_DIR.samefile(DIR_IN_GECKO), 'Run this script from the source git checkout.'
|
||||
assert DIR_IN_GECKO.as_posix().endswith(REL_PATH) # Be paranoid with rm -rf.
|
||||
assert DIR_IN_GECKO.as_posix().endswith(REL_PATH) # Be paranoid with rm -rf.
|
||||
|
||||
gecko_base_dir = DIR_IN_GECKO.as_posix()[:-len(REL_PATH)]
|
||||
angle_dir = Path(gecko_base_dir, 'gfx/angle').as_posix()
|
||||
sys.path.append(angle_dir)
|
||||
from vendor_from_git import *
|
||||
from vendor_from_git import print_now, record_cherry_picks
|
||||
|
||||
# --
|
||||
|
||||
(MERGE_BASE_ORIGIN, ) = sys.argv[1:] # Not always 'origin'!
|
||||
(MERGE_BASE_ORIGIN, ) = sys.argv[1:] # Not always 'origin'!
|
||||
record_cherry_picks(DIR_IN_GECKO, MERGE_BASE_ORIGIN)
|
||||
|
||||
# --
|
||||
|
|
|
@ -9,6 +9,7 @@ assert MOCHI_PATH.suffix == '.html'
|
|||
|
||||
TEST_PATH = MOCHI_PATH.with_suffix('.solo.html')
|
||||
|
||||
|
||||
def read_local_file(include):
|
||||
inc_path = MOCHI_PATH.parent
|
||||
file_path = inc_path / include
|
||||
|
@ -80,7 +81,7 @@ with open(TEST_PATH, 'wb') as fout:
|
|||
|
||||
if inc == b'/tests/SimpleTest/SimpleTest':
|
||||
print('Injecting SimpleTest replacement')
|
||||
fout.write(SIMPLETEST_REPLACEMENT);
|
||||
fout.write(SIMPLETEST_REPLACEMENT)
|
||||
continue
|
||||
|
||||
inc_js = inc.decode() + '.js'
|
||||
|
@ -90,9 +91,9 @@ with open(TEST_PATH, 'wb') as fout:
|
|||
continue
|
||||
|
||||
print('Injecting include: ' + inc_js)
|
||||
fout.write(b'\n<script>\n// Imported from: ' + inc_js.encode() + b'\n');
|
||||
fout.write(inc_data);
|
||||
fout.write(b'\n</script>\n');
|
||||
fout.write(b'\n<script>\n// Imported from: ' + inc_js.encode() + b'\n')
|
||||
fout.write(inc_data)
|
||||
fout.write(b'\n</script>\n')
|
||||
continue
|
||||
|
||||
if skip_line:
|
||||
|
@ -100,4 +101,3 @@ with open(TEST_PATH, 'wb') as fout:
|
|||
|
||||
fout.write(line)
|
||||
continue
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче