--- a/dom/canvas/test/webgl-conf/generate-wrappers-and-manifest.py
+++ b/dom/canvas/test/webgl-conf/generate-wrappers-and-manifest.py
@@ -14,20 +14,20 @@ CURRENT_VERSION = '1.0.3'
# 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'
GENERATED_PATHSTR = 'generated'
+PATH_SEP_MANGLING = '__'
SUPPORT_DIRS = [
- 'checkout/conformance',
- 'checkout/resources',
+ 'checkout',
]
EXTRA_SUPPORT_FILES = [
'always-fail.html',
'iframe-passthrough.css',
'mochi-single.html',
]
@@ -42,21 +42,26 @@ ACCEPTABLE_ERRATA_KEYS = set([
def GetTestList():
split = BASE_TEST_LIST_PATHSTR.rsplit('/', 1)
basePath = '.'
testListFile = split[-1]
if len(split) == 2:
basePath = split[0]
- curVersion = CURRENT_VERSION
- testList = ['always-fail.html']
- AccumTests(basePath, testListFile, curVersion, testList)
+ allowWebGL1 = True
+ allowWebGL2 = True
+ alwaysFailEntry = TestEntry('always-fail.html', True, False)
+ testList = [alwaysFailEntry]
+ AccumTests(basePath, testListFile, allowWebGL1, allowWebGL2, testList)
- testList = [os.path.relpath(x, basePath).replace(os.sep, '/') for x in testList]
+ for x in testList:
+ x.path = os.path.relpath(x.path, basePath).replace(os.sep, '/')
+ continue
+
return testList
##############################
# Internals
def IsVersionLess(a, b):
aSplit = [int(x) for x in a.split('.')]
bSplit = [int(x) for x in b.split('.')]
@@ -73,18 +78,25 @@ def IsVersionLess(a, b):
if aVal == bVal:
continue
return aVal < bVal
return False
+class TestEntry:
+ def __init__(self, path, webgl1, webgl2):
+ self.path = path
+ self.webgl1 = webgl1
+ self.webgl2 = webgl2
+ return
-def AccumTests(pathStr, listFile, curVersion, out_testList):
+
+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:
lineNum = 0
for line in fIn:
@@ -95,59 +107,60 @@ def AccumTests(pathStr, listFile, curVer
continue
curLine = line.lstrip()
if curLine.startswith('//'):
continue
if curLine.startswith('#'):
continue
- shouldSkip = False
+ webgl1 = allowWebGL1
+ webgl2 = allowWebGL2
while curLine.startswith('--'): # '--min-version 1.0.2 foo.html'
(flag, curLine) = curLine.split(' ', 1)
if flag == '--min-version':
- (refVersion, curLine) = curLine.split(' ', 1)
- if IsVersionLess(curVersion, refVersion):
- shouldSkip = True
+ (minVersion, curLine) = curLine.split(' ', 1)
+ if not IsVersionLess(minVersion, "2.0.0"): # >= 2.0.0
+ webgl1 = False
break
elif flag == '--max-version':
- (refVersion, curLine) = curLine.split(' ', 1)
- if IsVersionLess(refVersion, curVersion):
- shouldSkip = True
+ (maxVersion, curLine) = curLine.split(' ', 1)
+ if IsVersionLess(maxVersion, "2.0.0"):
+ webgl2 = False
break
elif flag == '--slow':
continue # TODO
else:
text = 'Unknown flag \'{}\': {}:{}: {}'.format(flag, listPath,
lineNum, line)
assert False, text
continue
- if shouldSkip:
- continue
+ assert(webgl1 or webgl2)
split = curLine.rsplit('.', 1)
assert len(split) == 2, 'Bad split for `line`: ' + line
(name, ext) = split
if ext == 'html':
newTestFilePathStr = pathStr + '/' + curLine
- out_testList.append(newTestFilePathStr)
+ entry = TestEntry(newTestFilePathStr, webgl1, webgl2)
+ out_testList.append(entry)
continue
assert ext == 'txt', 'Bad `ext` on `line`: ' + line
split = curLine.rsplit('/', 1)
nextListFile = split[-1]
nextPathStr = ''
if len(split) != 1:
nextPathStr = split[0]
nextPathStr = pathStr + '/' + nextPathStr
- AccumTests(nextPathStr, nextListFile, curVersion, out_testList)
+ AccumTests(nextPathStr, nextListFile, webgl1, webgl2, out_testList)
continue
return
########################################################################
# Templates
def FillTemplate(inFilePath, templateDict, outFilePath):
@@ -266,43 +279,62 @@ class TemplateShell:
indentLen += len(span)
continue
return ret
########################################################################
# Output
-def WriteWrappers(testWebPathStrList):
+def WriteWrapper(entryPath, webgl2, templateShell, wrapperPathAccum):
+ mangledPath = entryPath.replace('/', PATH_SEP_MANGLING)
+ maybeWebGL2 = ''
+ if webgl2:
+ maybeWebGL2 = '2_'
+
+ # Mochitests must start with 'test_' or similar, or the test
+ # runner will ignore our tests.
+ # The error text is "is not a valid test".
+ wrapperFileName = 'test_{}{}'.format(maybeWebGL2, mangledPath)
+
+ wrapperPath = GENERATED_PATHSTR + '/' + wrapperFileName
+ print('Adding wrapper: ' + wrapperPath)
+
+ args = ''
+ if webgl2:
+ args = '?webglVersion=2'
+
+ templateDict = {
+ 'TEST_PATH': entryPath,
+ 'ARGS': args,
+ }
+
+ OutputFilledTemplate(templateShell, templateDict, wrapperPath)
+ wrapperPathAccum.append(wrapperPath)
+ return
+
+
+def WriteWrappers(testEntryList):
templateShell = ImportTemplate(WRAPPER_TEMPLATE_FILE)
generatedDirPath = GENERATED_PATHSTR.replace('/', os.sep)
if not os.path.exists(generatedDirPath):
os.mkdir(generatedDirPath)
assert os.path.isdir(generatedDirPath)
- wrapperManifestPathStrList = []
- for testWebPathStr in testWebPathStrList:
- # Mochitests must start with 'test_' or similar, or the test
- # runner will ignore our tests.
- # The error text is "is not a valid test".
- wrapperFilePathStr = 'test_' + testWebPathStr.replace('/', '__')
- wrapperFilePathStr = GENERATED_PATHSTR + '/' + wrapperFilePathStr
- wrapperManifestPathStrList.append(wrapperFilePathStr)
-
- templateDict = {
- 'HEADER': '<!-- GENERATED FILE, DO NOT EDIT -->',
- 'TEST_PATH': testWebPathStr,
- }
-
- print 'Adding wrapper: ' + wrapperFilePathStr
- OutputFilledTemplate(templateShell, templateDict, wrapperFilePathStr)
+ wrapperPathList = []
+ for entry in testEntryList:
+ if entry.webgl1:
+ WriteWrapper(entry.path, False, templateShell, wrapperPathList)
+ if entry.webgl2:
+ WriteWrapper(entry.path, True, templateShell, wrapperPathList)
continue
- return wrapperManifestPathStrList
+ print('{} wrappers written.\n'.format(len(wrapperPathList)))
+ return wrapperPathList
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, '/')
@@ -418,17 +450,17 @@ def LoadErrata():
for (sectionName, (sectionLineNum, sectionMap)) in iniMap.iteritems():
curLines = []
if sectionName == None:
continue
elif sectionName != 'DEFAULT':
path = sectionName.replace('/', os.sep)
- assert os.path.exists(path), 'Line {}: {}'.format(sectionLineNum, sectionName)
+ assert os.path.exists(path), 'Errata line {}: Invalid file: {}'.format(sectionLineNum, sectionName)
for (key, (lineNum, val)) in sectionMap.iteritems():
assert key in ACCEPTABLE_ERRATA_KEYS, 'Line {}: {}'.format(lineNum, key)
curLine = '{} = {}'.format(key, val)
curLines.append(curLine)
continue
@@ -464,15 +496,15 @@ def GetFilePathListForDir(baseDir):
return ret
if __name__ == '__main__':
fileDir = os.path.dirname(__file__)
assert not fileDir, 'Run this file from its directory, not ' + fileDir
- testPathStrList = GetTestList()
- wrapperPathStrList = WriteWrappers(testPathStrList)
+ testEntryList = GetTestList()
+ wrapperPathStrList = WriteWrappers(testEntryList)
supportPathStrList = GetSupportFileList()
WriteManifest(wrapperPathStrList, supportPathStrList)
print('Done!')