Merge pull request #123 from domenic/whitespace-fixes

Whitespace fixes
This commit is contained in:
Brian Terlson 2014-12-01 13:04:42 -08:00
commit b53ba9f9c8
15 changed files with 133 additions and 133 deletions

View File

@ -1,7 +1,7 @@
# Copyright (c) 2012 Ecma International. All rights reserved. # Copyright (c) 2012 Ecma International. All rights reserved.
# Ecma International makes this code available under the terms and conditions set # Ecma International makes this code available under the terms and conditions set
# forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the # forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
# "Use Terms"). Any redistribution of this code must retain the above # "Use Terms"). Any redistribution of this code must retain the above
# copyright and this notice and otherwise comply with the Use Terms. # copyright and this notice and otherwise comply with the Use Terms.
@ -19,13 +19,13 @@ def getCoverageData(directory):
dirList = [x for x in tempList if os.path.isdir(os.path.join(directory, x))] dirList = [x for x in tempList if os.path.isdir(os.path.join(directory, x))]
#Build up a list of JavaScript files under the current directory #Build up a list of JavaScript files under the current directory
jsList = [x for xin in tempList if x.endswith(".js")] jsList = [x for xin in tempList if x.endswith(".js")]
#If the directory contains JavaScript files we'll assume they're all test #If the directory contains JavaScript files we'll assume they're all test
#cases #cases
if len(jsList)!=0: if len(jsList)!=0:
CVG_DICT[os.path.split(directory)[1]] = len(jsList) CVG_DICT[os.path.split(directory)[1]] = len(jsList)
#This might have just been a directory containing other dirs. Call ourself on #This might have just been a directory containing other dirs. Call ourself on
#it as well #it as well
for x in dirList: for x in dirList:
getCoverageData(os.path.join(directory, x)) getCoverageData(os.path.join(directory, x))
@ -61,4 +61,4 @@ def chapterCompare(x, y):
startDir = sys.argv[1] startDir = sys.argv[1]
getCoverageData(startDir) getCoverageData(startDir)
print "Emitting ECMAScript 5 coverage data for", startDir, "..." print "Emitting ECMAScript 5 coverage data for", startDir, "..."
emitCoverageData(CVG_DICT) emitCoverageData(CVG_DICT)

View File

@ -1,7 +1,7 @@
# Copyright (c) 2012 Ecma International. All rights reserved. # Copyright (c) 2012 Ecma International. All rights reserved.
# Ecma International makes this code available under the terms and conditions set # Ecma International makes this code available under the terms and conditions set
# forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the # forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
# "Use Terms"). Any redistribution of this code must retain the above # "Use Terms"). Any redistribution of this code must retain the above
# copyright and this notice and otherwise comply with the Use Terms. # copyright and this notice and otherwise comply with the Use Terms.
#--Imports--------------------------------------------------------------------- #--Imports---------------------------------------------------------------------
@ -34,7 +34,7 @@ def getAllJSFiles(dirName):
def handleFile(filePath): def handleFile(filePath):
with open(filePath, "r") as f: with open(filePath, "r") as f:
origLines = f.readlines() origLines = f.readlines()
testCase = False testCase = False
runTestCaseCalled = False runTestCaseCalled = False
for line in origLines: for line in origLines:
@ -42,15 +42,15 @@ def handleFile(filePath):
testCase = True testCase = True
if runTestCaseRe.search(line)!=None: if runTestCaseRe.search(line)!=None:
runTestCaseCalled = True runTestCaseCalled = True
if testCase==True and runTestCaseCalled==True: if testCase==True and runTestCaseCalled==True:
pass #print "testcase TEST:", filePath pass #print "testcase TEST:", filePath
elif testCase==False and runTestCaseCalled==False: elif testCase==False and runTestCaseCalled==False:
pass #print "GLOBAL TEST:", filePath pass #print "GLOBAL TEST:", filePath
else: else:
print "ERROR:", filePath print "ERROR:", filePath
#--Main------------------------------------------------------------------------ #--Main------------------------------------------------------------------------
if __name__=="__main__": if __name__=="__main__":
@ -61,8 +61,8 @@ if __name__=="__main__":
if not os.path.exists(ARGS.tpath): if not os.path.exists(ARGS.tpath):
print "Cannot examine tests in '%s' when it doesn't exist!" % ARGS.tpath print "Cannot examine tests in '%s' when it doesn't exist!" % ARGS.tpath
sys.exit(1) sys.exit(1)
ALL_JS_FILES = getAllJSFiles(ARGS.tpath) ALL_JS_FILES = getAllJSFiles(ARGS.tpath)
for fileName in ALL_JS_FILES: for fileName in ALL_JS_FILES:
handleFile(fileName) handleFile(fileName)
print "Done!" print "Done!"

View File

@ -1,7 +1,7 @@
# Copyright (c) 2012 Ecma International. All rights reserved. # Copyright (c) 2012 Ecma International. All rights reserved.
# Ecma International makes this code available under the terms and conditions set # Ecma International makes this code available under the terms and conditions set
# forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the # forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
# "Use Terms"). Any redistribution of this code must retain the above # "Use Terms"). Any redistribution of this code must retain the above
# copyright and this notice and otherwise comply with the Use Terms. # copyright and this notice and otherwise comply with the Use Terms.
#--Imports--------------------------------------------------------------------- #--Imports---------------------------------------------------------------------
@ -12,10 +12,10 @@ import re
import codecs import codecs
#--Globals--------------------------------------------------------------------- #--Globals---------------------------------------------------------------------
ECMA_LICENSE = '''/// Copyright (c) 2012 Ecma International. All rights reserved. ECMA_LICENSE = '''/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set /// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
/// "Use Terms"). Any redistribution of this code must retain the above /// "Use Terms"). Any redistribution of this code must retain the above
/// copyright and this notice and otherwise comply with the Use Terms. /// copyright and this notice and otherwise comply with the Use Terms.
''' '''
@ -50,12 +50,12 @@ def handleFile(filePath):
''' '''
with open(filePath, "rb") as f: with open(filePath, "rb") as f:
origLines = f.readlines() origLines = f.readlines()
#See if it's already there #See if it's already there
if NEW_LICENSE_FIRST_LINE.search(origLines[0])!=None: if NEW_LICENSE_FIRST_LINE.search(origLines[0])!=None:
#print "\talready there:\t", filePath #print "\talready there:\t", filePath
return return
#TODO: Google employee needs to remove this elif #TODO: Google employee needs to remove this elif
# and fix the next elif clause # and fix the next elif clause
elif GOOGLE_RE.search(filePath)!=None: elif GOOGLE_RE.search(filePath)!=None:
if DEBUG: if DEBUG:
@ -65,13 +65,13 @@ def handleFile(filePath):
errMsg = "\tno idea which license should be used for:\t" + filePath errMsg = "\tno idea which license should be used for:\t" + filePath
raise Exception(errMsg) raise Exception(errMsg)
return return
with codecs.open(filePath,'r','utf8') as f: with codecs.open(filePath,'r','utf8') as f:
bomPresent = f.read(2).startswith(u"\ufeff") bomPresent = f.read(2).startswith(u"\ufeff")
if bomPresent: if bomPresent:
print "\tnon-ASCII file detected. Please modify by hand:", filePath print "\tnon-ASCII file detected. Please modify by hand:", filePath
return return
with open(filePath, "wb") as f: with open(filePath, "wb") as f:
if DEBUG: if DEBUG:
print "\tmodified:\t", filePath print "\tmodified:\t", filePath
@ -80,14 +80,14 @@ def handleFile(filePath):
# print "\tBOM was detected for:", filePath # print "\tBOM was detected for:", filePath
# f.write(u"\ufeff") # f.write(u"\ufeff")
f.write(ECMA_LICENSE) f.write(ECMA_LICENSE)
writeIt = False writeIt = False
for line in origLines: for line in origLines:
if writeIt: if writeIt:
f.write(line) f.write(line)
elif OLD_LICENSE_LAST_LINE.search(line)!=None: elif OLD_LICENSE_LAST_LINE.search(line)!=None:
writeIt = True writeIt = True
if not writeIt: if not writeIt:
print "\tError - didn't find end of the original license:\t", filePath print "\tError - didn't find end of the original license:\t", filePath
@ -100,8 +100,8 @@ if __name__=="__main__":
if not os.path.exists(ARGS.tpath): if not os.path.exists(ARGS.tpath):
print "Cannot fix tests in '%s' when it doesn't exist!" % ARGS.tpath print "Cannot fix tests in '%s' when it doesn't exist!" % ARGS.tpath
sys.exit(1) sys.exit(1)
ALL_JS_FILES = getAllJSFiles(ARGS.tpath) ALL_JS_FILES = getAllJSFiles(ARGS.tpath)
for fileName in ALL_JS_FILES: for fileName in ALL_JS_FILES:
handleFile(fileName) handleFile(fileName)
print "Done!" print "Done!"

View File

@ -1,7 +1,7 @@
# Copyright (c) 2012 Ecma International. All rights reserved. # Copyright (c) 2012 Ecma International. All rights reserved.
# Ecma International makes this code available under the terms and conditions set # Ecma International makes this code available under the terms and conditions set
# forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the # forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
# "Use Terms"). Any redistribution of this code must retain the above # "Use Terms"). Any redistribution of this code must retain the above
# copyright and this notice and otherwise comply with the Use Terms. # copyright and this notice and otherwise comply with the Use Terms.
#--Imports--------------------------------------------------------------------- #--Imports---------------------------------------------------------------------
@ -34,15 +34,15 @@ def handleFile(filePath, partialPath):
global PRE_PATH global PRE_PATH
tempPath = filePath.replace(partialPath + os.path.sep, "", 1) tempPath = filePath.replace(partialPath + os.path.sep, "", 1)
tempPath = tempPath.replace(os.path.sep, "/") tempPath = tempPath.replace(os.path.sep, "/")
with open(filePath, "rb") as f: with open(filePath, "rb") as f:
origLines = f.readlines() origLines = f.readlines()
with open(filePath, "wb") as f: with open(filePath, "wb") as f:
pathHit = False pathHit = False
#testHit = False #testHit = False
#descriptHit = False #descriptHit = False
for line in origLines: for line in origLines:
#TODO? #TODO?
#if (not testHit) and re.match("^$", line)!=None: #if (not testHit) and re.match("^$", line)!=None:
@ -56,8 +56,8 @@ def handleFile(filePath, partialPath):
if line.endswith("\r\n"): if line.endswith("\r\n"):
lineEnding = "\r\n" lineEnding = "\r\n"
pathHit = True pathHit = True
line = re.sub(r"@path\s+[^$]+$", #"\"[^\"]*\"", line = re.sub(r"@path\s+[^$]+$", #"\"[^\"]*\"",
r"@path %s%s" % (PRE_PATH + tempPath, lineEnding), r"@path %s%s" % (PRE_PATH + tempPath, lineEnding),
line) line)
#TODO? #TODO?
#elif (not descriptHit) and re.search("description\s*:\s*\"", line)!=None: #elif (not descriptHit) and re.search("description\s*:\s*\"", line)!=None:
@ -74,8 +74,8 @@ if __name__=="__main__":
if not os.path.exists(ARGS.tpath): if not os.path.exists(ARGS.tpath):
print "Cannot fix tests in '%s' when it doesn't exist!" % ARGS.tpath print "Cannot fix tests in '%s' when it doesn't exist!" % ARGS.tpath
sys.exit(1) sys.exit(1)
ALL_JS_FILES = getAllJSFiles(ARGS.tpath) ALL_JS_FILES = getAllJSFiles(ARGS.tpath)
for fileName in ALL_JS_FILES: for fileName in ALL_JS_FILES:
handleFile(fileName, ARGS.tpath) handleFile(fileName, ARGS.tpath)
print "Done!" print "Done!"

View File

@ -1,7 +1,7 @@
# Copyright (c) 2012 Ecma International. All rights reserved. # Copyright (c) 2012 Ecma International. All rights reserved.
# Ecma International makes this code available under the terms and conditions set # Ecma International makes this code available under the terms and conditions set
# forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the # forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
# "Use Terms"). Any redistribution of this code must retain the above # "Use Terms"). Any redistribution of this code must retain the above
# copyright and this notice and otherwise comply with the Use Terms. # copyright and this notice and otherwise comply with the Use Terms.
#--Imports--------------------------------------------------------------------- #--Imports---------------------------------------------------------------------
@ -32,20 +32,20 @@ def getAllJSFiles(dirName):
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def handleFile(filePath, partialPath): def handleFile(filePath, partialPath):
global PRE_PATH global PRE_PATH
tempPath = filePath.replace(partialPath + os.path.sep, "", 1) tempPath = filePath.replace(partialPath + os.path.sep, "", 1)
tempPath = tempPath.replace(os.path.sep, "/") tempPath = tempPath.replace(os.path.sep, "/")
tempId = tempPath.rsplit("/", 1)[1][:-3] tempId = tempPath.rsplit("/", 1)[1][:-3]
with open(filePath, "r") as f: with open(filePath, "r") as f:
origLines = f.readlines() origLines = f.readlines()
with open(filePath, "w") as f: with open(filePath, "w") as f:
pathHit = False pathHit = False
idHit = False idHit = False
testHit = False testHit = False
descriptHit = False descriptHit = False
for line in origLines: for line in origLines:
if (not testHit) and re.match("^$", line)!=None: if (not testHit) and re.match("^$", line)!=None:
#Throw away empty lines until we hit the first test function #Throw away empty lines until we hit the first test function
@ -71,7 +71,7 @@ def getPartialPath(tc):
sys.exit(1) sys.exit(1)
elif not ("." in tc): elif not ("." in tc):
tc = tc.replace("-", ".0-", 1) tc = tc.replace("-", ".0-", 1)
#Generate the partial path of the test case #Generate the partial path of the test case
tempList = tc.split("-",1)[0].split(".") tempList = tc.split("-",1)[0].split(".")
partialPath = "" partialPath = ""
@ -96,15 +96,15 @@ if __name__=="__main__":
help='Command used to remove a test file from source control') help='Command used to remove a test file from source control')
__parser.add_argument('tc', action='store', __parser.add_argument('tc', action='store',
help='test case to move') help='test case to move')
ARGS = __parser.parse_args() ARGS = __parser.parse_args()
if not os.path.exists(ARGS.path): if not os.path.exists(ARGS.path):
print "Cannot fix tests in '%s' when it doesn't exist!" % ARGS.path print "Cannot fix tests in '%s' when it doesn't exist!" % ARGS.path
sys.exit(1) sys.exit(1)
elif not os.path.isfile(ARGS.tc): elif not os.path.isfile(ARGS.tc):
print "Cannot move '%s' when it doesn't exist!" % ARGS.tc print "Cannot move '%s' when it doesn't exist!" % ARGS.tc
partialPath = getPartialPath(ARGS.tc) partialPath = getPartialPath(ARGS.tc)
print "Done!", partialPath print "Done!", partialPath

View File

@ -1,7 +1,7 @@
# Copyright (c) 2012 Ecma International. All rights reserved. # Copyright (c) 2012 Ecma International. All rights reserved.
# Ecma International makes this code available under the terms and conditions set # Ecma International makes this code available under the terms and conditions set
# forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the # forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
# "Use Terms"). Any redistribution of this code must retain the above # "Use Terms"). Any redistribution of this code must retain the above
# copyright and this notice and otherwise comply with the Use Terms. # copyright and this notice and otherwise comply with the Use Terms.
#--Imports--------------------------------------------------------------------- #--Imports---------------------------------------------------------------------
@ -14,7 +14,7 @@ import re
#List of regular expressions covering suspect code snippets which might be #List of regular expressions covering suspect code snippets which might be
#invalid from an ES5 POV #invalid from an ES5 POV
QUESTIONABLE_RE_LIST = ["window", QUESTIONABLE_RE_LIST = ["window",
"document(?!ation)", "document(?!ation)",
"alert", "alert",
"setTimeout", "setTimeout",
@ -42,7 +42,7 @@ def getAllJSFiles(dirName):
def handleFile(filePath): def handleFile(filePath):
with open(filePath, "r") as f: with open(filePath, "r") as f:
origLines = f.readlines() origLines = f.readlines()
for line in origLines: for line in origLines:
for tempRe in QUESTIONABLE_RE_LIST: for tempRe in QUESTIONABLE_RE_LIST:
if tempRe.search(line)!=None: if tempRe.search(line)!=None:
@ -58,8 +58,8 @@ if __name__=="__main__":
if not os.path.exists(ARGS.tpath): if not os.path.exists(ARGS.tpath):
print "Cannot examine tests in '%s' when it doesn't exist!" % ARGS.tpath print "Cannot examine tests in '%s' when it doesn't exist!" % ARGS.tpath
sys.exit(1) sys.exit(1)
ALL_JS_FILES = getAllJSFiles(ARGS.tpath) ALL_JS_FILES = getAllJSFiles(ARGS.tpath)
for fileName in ALL_JS_FILES: for fileName in ALL_JS_FILES:
handleFile(fileName) handleFile(fileName)
print "Done!" print "Done!"

View File

@ -1,7 +1,7 @@
# Copyright (c) 2012 Ecma International. All rights reserved. # Copyright (c) 2012 Ecma International. All rights reserved.
# Ecma International makes this code available under the terms and conditions set # Ecma International makes this code available under the terms and conditions set
# forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the # forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
# "Use Terms"). Any redistribution of this code must retain the above # "Use Terms"). Any redistribution of this code must retain the above
# copyright and this notice and otherwise comply with the Use Terms. # copyright and this notice and otherwise comply with the Use Terms.
#--Imports--------------------------------------------------------------------- #--Imports---------------------------------------------------------------------
@ -17,5 +17,5 @@ def convertDocString(docString):
envelope = parseTestRecord.parseTestRecord(docString, '') envelope = parseTestRecord.parseTestRecord(docString, '')
envelope.pop('header', None) envelope.pop('header', None)
envelope.pop('test', None) envelope.pop('test', None)
return envelope return envelope

View File

@ -21,7 +21,7 @@ def load(str):
line = lines.pop(0) line = lines.pop(0)
if myIsAllSpaces(line): if myIsAllSpaces(line):
continue continue
result = mYamlKV.match(line) result = mYamlKV.match(line)
if result: if result:
if not dict: if not dict:
dict = {} dict = {}
@ -62,7 +62,7 @@ def myMultilineList(lines, value):
indent = indent or leading indent = indent or leading
value += [myReadOneLine(myRemoveListHeader(indent, line))] value += [myReadOneLine(myRemoveListHeader(indent, line))]
return (lines, value) return (lines, value)
def myRemoveListHeader(indent, line): def myRemoveListHeader(indent, line):
line = line[indent:] line = line[indent:]
return mYamlMultilineList.match(line).group(1) return mYamlMultilineList.match(line).group(1)
@ -81,7 +81,7 @@ def myReadOneLine(value):
except ValueError: except ValueError:
pass pass
return value return value
def myFlowList(value): def myFlowList(value):
result = mYamlListPattern.match(value) result = mYamlListPattern.match(value)
values = result.group(1).split(",") values = result.group(1).split(",")

View File

@ -1,7 +1,7 @@
# Copyright (c) 2012 Ecma International. All rights reserved. # Copyright (c) 2012 Ecma International. All rights reserved.
# Ecma International makes this code available under the terms and conditions set # Ecma International makes this code available under the terms and conditions set
# forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the # forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
# "Use Terms"). Any redistribution of this code must retain the above # "Use Terms"). Any redistribution of this code must retain the above
# copyright and this notice and otherwise comply with the Use Terms. # copyright and this notice and otherwise comply with the Use Terms.
#--Imports--------------------------------------------------------------------- #--Imports---------------------------------------------------------------------
@ -87,14 +87,14 @@ def createDepDirs(dirName):
os.mkdir(dirName) os.mkdir(dirName)
def test262PathToConsoleFile(path): def test262PathToConsoleFile(path):
stuff = os.path.join(TEST262_CONSOLE_CASES_DIR, stuff = os.path.join(TEST262_CONSOLE_CASES_DIR,
path.replace("/", os.path.sep)) path.replace("/", os.path.sep))
createDepDirs(os.path.dirname(stuff)) createDepDirs(os.path.dirname(stuff))
return stuff return stuff
def getJSCount(dirName): def getJSCount(dirName):
''' '''
Returns the total number of *.js files (recursively) under a given Returns the total number of *.js files (recursively) under a given
directory, dirName. directory, dirName.
''' '''
retVal = 0 retVal = 0
@ -143,7 +143,7 @@ def dirWalker(dirName):
def isTestStarted(line): def isTestStarted(line):
''' '''
Used to detect if we've gone past extraneous test comments in a test case. Used to detect if we've gone past extraneous test comments in a test case.
Note this is a naive approach on the sense that "/*abc*/" could be on one Note this is a naive approach on the sense that "/*abc*/" could be on one
line. However, we know for a fact this is not the case in IE Test Center line. However, we know for a fact this is not the case in IE Test Center
or Sputnik tests. or Sputnik tests.
@ -170,7 +170,7 @@ for temp in os.listdir(TEST262_CASES_DIR):
if not os.path.exists(temp): if not os.path.exists(temp):
print "The expected ES5 test directory,", temp, "did not exist!" print "The expected ES5 test directory,", temp, "did not exist!"
sys.exit(1) sys.exit(1)
if temp.find("/.") != -1: if temp.find("/.") != -1:
# skip hidden files on Unix, such as ".DS_Store" on Mac # skip hidden files on Unix, such as ".DS_Store" on Mac
continue continue
@ -187,11 +187,11 @@ for chapter in TEST_SUITE_SECTIONS:
testsList = {} testsList = {}
sect = {} sect = {}
sect["name"] = "Chapter - " + chapterName sect["name"] = "Chapter - " + chapterName
#create an array for tests in a chapter #create an array for tests in a chapter
tests = [] tests = []
sourceFiles = getAllJSFiles(chapter) sourceFiles = getAllJSFiles(chapter)
if len(sourceFiles)!=0: if len(sourceFiles)!=0:
excluded = 0 excluded = 0
testCount = 0 testCount = 0
@ -199,13 +199,13 @@ for chapter in TEST_SUITE_SECTIONS:
#TODO - use something other than the hard-coded 'TestCases' below #TODO - use something other than the hard-coded 'TestCases' below
testPath = "TestCases" + \ testPath = "TestCases" + \
test.split(TEST262_CASES_DIR, 1)[1].replace("\\", "/") test.split(TEST262_CASES_DIR, 1)[1].replace("\\", "/")
testName=test.rsplit(".", 1)[0] testName=test.rsplit(".", 1)[0]
testName=testName.rsplit(os.path.sep, 1)[1] testName=testName.rsplit(os.path.sep, 1)[1]
if EXCLUDE_LIST.count(testName)==0: if EXCLUDE_LIST.count(testName)==0:
# dictionary for each test # dictionary for each test
testDict = {} testDict = {}
testDict["path"] = testPath testDict["path"] = testPath
tempFile = open(test, "rb") tempFile = open(test, "rb")
scriptCode = tempFile.readlines() scriptCode = tempFile.readlines()
tempFile.close() tempFile.close()
@ -232,7 +232,7 @@ for chapter in TEST_SUITE_SECTIONS:
scriptCodeContentB64 = base64.b64encode(scriptCodeContent) scriptCodeContentB64 = base64.b64encode(scriptCodeContent)
#add the test encoded code node to our test dictionary #add the test encoded code node to our test dictionary
testDict["code"] = scriptCodeContentB64 testDict["code"] = scriptCodeContentB64
#now close the dictionary for the test #now close the dictionary for the test
#now get the metadata added. #now get the metadata added.
@ -245,7 +245,7 @@ for chapter in TEST_SUITE_SECTIONS:
#this adds the test to our tests array #this adds the test to our tests array
tests.append(testDict) tests.append(testDict)
if ARGS.console: if ARGS.console:
with open(test262PathToConsoleFile(testDict["path"]), with open(test262PathToConsoleFile(testDict["path"]),
"w") as fConsole: "w") as fConsole:
@ -268,7 +268,7 @@ for chapter in TEST_SUITE_SECTIONS:
#create a node for the tests and add it to our testsLists #create a node for the tests and add it to our testsLists
testsList["testsCollection"] = sect testsList["testsCollection"] = sect
with open(os.path.join(TEST262_WEB_CASES_DIR, chapterName + ".json"), with open(os.path.join(TEST262_WEB_CASES_DIR, chapterName + ".json"),
"w") as f: "w") as f:
json.dump(testsList, f, separators=(',',':'), sort_keys=True, json.dump(testsList, f, separators=(',',':'), sort_keys=True,
indent=0) indent=0)
@ -279,12 +279,12 @@ for chapter in TEST_SUITE_SECTIONS:
CHAPTER_TEST_CASES_JSON["numTests"] = int(sect["numTests"]) CHAPTER_TEST_CASES_JSON["numTests"] = int(sect["numTests"])
CHAPTER_TEST_CASES_JSON["testSuite"] = \ CHAPTER_TEST_CASES_JSON["testSuite"] = \
[WEBSITE_CASES_PATH + chapterName + ".json"] [WEBSITE_CASES_PATH + chapterName + ".json"]
with open(os.path.join(TEST262_WEB_CASES_DIR, with open(os.path.join(TEST262_WEB_CASES_DIR,
"testcases_%s.json" % chapterName), "testcases_%s.json" % chapterName),
"w") as f: "w") as f:
json.dump(CHAPTER_TEST_CASES_JSON, f, separators=(',',':'), json.dump(CHAPTER_TEST_CASES_JSON, f, separators=(',',':'),
sort_keys=True, indent=0) sort_keys=True, indent=0)
generateHarness(ARGS.type, "testcases_%s.json" % chapterName, generateHarness(ARGS.type, "testcases_%s.json" % chapterName,
chapterName.replace("ch", "Chapter ")) chapterName.replace("ch", "Chapter "))
#add the name of the chapter test to our complete list #add the name of the chapter test to our complete list
@ -321,9 +321,9 @@ if TEST262_HARNESS_DIR!=TEST262_WEB_HARNESS_DIR:
if x.endswith(".js")]: if x.endswith(".js")]:
toFilenameList = [ os.path.join(TEST262_WEB_HARNESS_DIR, filename)] toFilenameList = [ os.path.join(TEST262_WEB_HARNESS_DIR, filename)]
if ARGS.console: if ARGS.console:
toFilenameList.append(os.path.join(TEST262_CONSOLE_HARNESS_DIR, toFilenameList.append(os.path.join(TEST262_CONSOLE_HARNESS_DIR,
filename)) filename))
for toFilename in toFilenameList: for toFilename in toFilenameList:
if not os.path.exists(os.path.dirname(toFilename)): if not os.path.exists(os.path.dirname(toFilename)):
os.mkdir(os.path.dirname(toFilename)) os.mkdir(os.path.dirname(toFilename))

View File

@ -1,7 +1,7 @@
# Copyright (c) 2012 Ecma International. All rights reserved. # Copyright (c) 2012 Ecma International. All rights reserved.
# Ecma International makes this code available under the terms and conditions set # Ecma International makes this code available under the terms and conditions set
# forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the # forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
# "Use Terms"). Any redistribution of this code must retain the above # "Use Terms"). Any redistribution of this code must retain the above
# copyright and this notice and otherwise comply with the Use Terms. # copyright and this notice and otherwise comply with the Use Terms.
#--Imports--------------------------------------------------------------------- #--Imports---------------------------------------------------------------------
@ -22,7 +22,7 @@ ONE_JSON_PER_CHAPTER = False
TESTCASELIST_PER_JSON = True TESTCASELIST_PER_JSON = True
#Path to the root of the Hg repository (relative to this file's location) #Path to the root of the Hg repository (relative to this file's location)
TEST262_ROOT = os.path.join(os.path.dirname(os.path.realpath(__file__)), TEST262_ROOT = os.path.join(os.path.dirname(os.path.realpath(__file__)),
"..", "..") "..", "..")
TEST262_ROOT = os.path.abspath(TEST262_ROOT) TEST262_ROOT = os.path.abspath(TEST262_ROOT)
@ -40,9 +40,9 @@ TEST262_CONSOLE_CASES_DIR = os.path.join(TEST262_ROOT, CONSOLE_SHORT_NAME)
#Directory containing the website's test harness (ported over from #Directory containing the website's test harness (ported over from
#TEST262_HARNESS_DIR) #TEST262_HARNESS_DIR)
TEST262_WEB_HARNESS_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, TEST262_WEB_HARNESS_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME,
"harness") "harness")
TEST262_CONSOLE_HARNESS_DIR = os.path.join(TEST262_ROOT, CONSOLE_SHORT_NAME, TEST262_CONSOLE_HARNESS_DIR = os.path.join(TEST262_ROOT, CONSOLE_SHORT_NAME,
"harness") "harness")
#Path to the ported test case files on the actual website as opposed #Path to the ported test case files on the actual website as opposed
@ -66,20 +66,20 @@ __lastHarnessType = None
def generateHarness(harnessType, jsonName, title): def generateHarness(harnessType, jsonName, title):
global TEMPLATE_LINES global TEMPLATE_LINES
global __lastHarnessType global __lastHarnessType
#TODO: temp hack to make experimental internationalization tests work #TODO: temp hack to make experimental internationalization tests work
if jsonName=="testcases_intl402.json": if jsonName=="testcases_intl402.json":
harnessType = "intl402" harnessType = "intl402"
elif jsonName=="testcases_bestPractice.json": elif jsonName=="testcases_bestPractice.json":
harnessType = "bestPractice" harnessType = "bestPractice"
if TEMPLATE_LINES==None or harnessType!=__lastHarnessType: if TEMPLATE_LINES==None or harnessType!=__lastHarnessType:
__lastHarnessType = harnessType __lastHarnessType = harnessType
TEMPLATE_LINES = [] TEMPLATE_LINES = []
with open(os.path.join(os.getcwd(), "templates", with open(os.path.join(os.getcwd(), "templates",
"runner." + harnessType + ".html"), "r") as f: "runner." + harnessType + ".html"), "r") as f:
TEMPLATE_LINES = f.readlines() TEMPLATE_LINES = f.readlines()
fileName = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, fileName = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME,
jsonName.replace(".json", ".html")) jsonName.replace(".json", ".html"))
fileNameExists = False fileNameExists = False
if os.path.exists(fileName): if os.path.exists(fileName):
@ -91,7 +91,7 @@ def generateHarness(harnessType, jsonName, title):
f.write(" var TEST_LIST_PATH = \"json/" + jsonName + \ f.write(" var TEST_LIST_PATH = \"json/" + jsonName + \
"\";" + os.linesep) "\";" + os.linesep)
#elif "ECMAScript 5" in line: #elif "ECMAScript 5" in line:
# f.write(line.replace("ECMAScript 5", # f.write(line.replace("ECMAScript 5",
# "ECMAScript 5: %s" % title)) # "ECMAScript 5: %s" % title))
else: else:
f.write(line) f.write(line)
@ -101,7 +101,7 @@ def generateHarness(harnessType, jsonName, title):
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
class SCAbstraction(object): class SCAbstraction(object):
''' '''
A class which abstracts working with source control systems in relation to A class which abstracts working with source control systems in relation to
generated test262 files. Useful when test262 is also used internally by generated test262 files. Useful when test262 is also used internally by
browser implementors. browser implementors.
''' '''
@ -112,11 +112,11 @@ class SCAbstraction(object):
''' '''
if not(os.stat(filename).st_mode & stat.S_IWRITE): if not(os.stat(filename).st_mode & stat.S_IWRITE):
os.chmod(filename, stat.S_IWRITE) os.chmod(filename, stat.S_IWRITE)
def add(self, filename): def add(self, filename):
''' '''
Source control add of a file. Source control add of a file.
''' '''
subprocess.call(["git", "add", filename]) subprocess.call(["git", "add", filename])
SC_HELPER = SCAbstraction() SC_HELPER = SCAbstraction()

View File

@ -69,7 +69,7 @@ def oldAttrParser(testRecord, body, name):
raise Exception('Malformed "@" attribute: ' + name) raise Exception('Malformed "@" attribute: ' + name)
propName = propMatch.group(0) propName = propMatch.group(0)
propVal = stripStars(propText[len(propName):]) propVal = stripStars(propText[len(propName):])
if propName in testRecord: if propName in testRecord:
raise Exception('duplicate: ' + propName) raise Exception('duplicate: ' + propName)
testRecord[propName] = propVal; testRecord[propName] = propVal;
@ -89,7 +89,7 @@ def yamlAttrParser(testRecord, attrs, name):
if key == "info": if key == "info":
key = "commentary" key = "commentary"
testRecord[key] = value testRecord[key] = value
if 'flags' in testRecord: if 'flags' in testRecord:
for flag in testRecord['flags']: for flag in testRecord['flags']:
testRecord[flag] = "" testRecord[flag] = ""

View File

@ -47,7 +47,7 @@ class TestYAMLParsing(unittest.TestCase):
name = 'fixtures/test262-yaml-headers.js' name = 'fixtures/test262-yaml-headers.js'
contents = slurpFile(name) contents = slurpFile(name)
record = convertDocString(contents) record = convertDocString(contents)
self.assertEqual("The production Block { } in strict code can't contain function declaration;\n", record['commentary']) self.assertEqual("The production Block { } in strict code can't contain function declaration;\n", record['commentary'])
self.assertEqual("Trying to declare function at the Block statement", self.assertEqual("Trying to declare function at the Block statement",

View File

@ -29,7 +29,7 @@ class TestOldParsing(unittest.TestCase):
name = 'fixtures/test262-old-headers.js' name = 'fixtures/test262-old-headers.js'
contents = slurpFile(name) contents = slurpFile(name)
record = parseTestRecord(contents, name) record = parseTestRecord(contents, name)
self.assertEqual("""// Copyright 2009 the Sputnik authors. All rights reserved. self.assertEqual("""// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.""", // This code is governed by the BSD license found in the LICENSE file.""",
record['header']) record['header'])
@ -69,7 +69,7 @@ declaration;""", record['commentary'])
1; 1;
""" """
, "name") , "name")
def test_malformed(self): def test_malformed(self):
with self.assertRaisesRegexp(Exception, 'Malformed "@" attribute: name'): with self.assertRaisesRegexp(Exception, 'Malformed "@" attribute: name'):
parseTestRecord(""" parseTestRecord("""
@ -90,7 +90,7 @@ declaration;""", record['commentary'])
self.assertEqual("@foo bar", stripStars("\n* @foo bar")) self.assertEqual("@foo bar", stripStars("\n* @foo bar"))
self.assertEqual("@foo bar", stripStars("\n *@foo bar")) self.assertEqual("@foo bar", stripStars("\n *@foo bar"))
class TestYAMLParsing(unittest.TestCase): class TestYAMLParsing(unittest.TestCase):
def test_test(self): def test_test(self):
self.assertTrue(True) self.assertTrue(True)
@ -112,7 +112,7 @@ flags: [onlyStrict]
def test_yamlParse(self): def test_yamlParse(self):
text = """ text = """
info: > info: >
The production Block { } in strict code can't contain function The production Block { } in strict code can't contain function
declaration; declaration;
description: Trying to declare function at the Block statement description: Trying to declare function at the Block statement
@ -150,7 +150,7 @@ flags: [onlyStrict]"""
name = 'fixtures/test262-yaml-headers.js' name = 'fixtures/test262-yaml-headers.js'
contents = slurpFile(name) contents = slurpFile(name)
record = parseTestRecord(contents, name) record = parseTestRecord(contents, name)
self.assertEqual("""// Copyright 2009 the Sputnik authors. All rights reserved. self.assertEqual("""// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.""", // This code is governed by the BSD license found in the LICENSE file.""",
record['header']) record['header'])

View File

@ -43,7 +43,7 @@ class MockResult(object):
def __init__(self, case): def __init__(self, case):
self.case = case self.case = case
class TestTestSuite(unittest.TestCase): class TestTestSuite(unittest.TestCase):

View File

@ -54,7 +54,7 @@ EXCLUDE_LIST = [x.getAttribute("id") for x in EXCLUDE_LIST]
def BuildOptions(): def BuildOptions():
result = optparse.OptionParser() result = optparse.OptionParser()
result.add_option("--command", default=None, help="The command-line to run") result.add_option("--command", default=None, help="The command-line to run")
result.add_option("--tests", default=path.abspath('.'), result.add_option("--tests", default=path.abspath('.'),
help="Path to the tests") help="Path to the tests")
result.add_option("--cat", default=False, action="store_true", result.add_option("--cat", default=False, action="store_true",
help="Print packaged test code that would be run") help="Print packaged test code that would be run")
@ -62,18 +62,18 @@ def BuildOptions():
help="Print summary after running tests") help="Print summary after running tests")
result.add_option("--full-summary", default=False, action="store_true", result.add_option("--full-summary", default=False, action="store_true",
help="Print summary and test output after running tests") help="Print summary and test output after running tests")
result.add_option("--strict_only", default=False, action="store_true", result.add_option("--strict_only", default=False, action="store_true",
help="Test only strict mode") help="Test only strict mode")
result.add_option("--non_strict_only", default=False, action="store_true", result.add_option("--non_strict_only", default=False, action="store_true",
help="Test only non-strict mode") help="Test only non-strict mode")
# TODO: Once enough tests are made strict compat, change the default # TODO: Once enough tests are made strict compat, change the default
# to "both" # to "both"
result.add_option("--unmarked_default", default="non_strict", result.add_option("--unmarked_default", default="non_strict",
help="default mode for tests of unspecified strictness") help="default mode for tests of unspecified strictness")
result.add_option("--logname", help="Filename to save stdout to") result.add_option("--logname", help="Filename to save stdout to")
result.add_option("--junitname", help="Filename to save test results in JUnit XML format") result.add_option("--junitname", help="Filename to save test results in JUnit XML format")
result.add_option("--loglevel", default="warning", result.add_option("--loglevel", default="warning",
help="sets log level to debug, info, warning, error, or critical") help="sets log level to debug, info, warning, error, or critical")
result.add_option("--print-handle", default="print", help="Command to print from console") result.add_option("--print-handle", default="print", help="Command to print from console")
result.add_option("--list-includes", default=False, action="store_true", result.add_option("--list-includes", default=False, action="store_true",
help="List includes required by tests") help="List includes required by tests")
@ -169,13 +169,13 @@ class TestResult(object):
err = self.stderr.strip() err = self.stderr.strip()
if len(err) > 0: if len(err) > 0:
target.write("--- errors --- \n %s" % err) target.write("--- errors --- \n %s" % err)
def XmlAssemble(self, result): def XmlAssemble(self, result):
test_name = self.case.GetName() test_name = self.case.GetName()
test_mode = self.case.GetMode() test_mode = self.case.GetMode()
testCaseElement = xmlj.Element("testcase") testCaseElement = xmlj.Element("testcase")
testpath = self.TestPathManipulation(test_name) testpath = self.TestPathManipulation(test_name)
testCaseElement.attrib["classname"] = "%s.%s" % (testpath[0] , testpath[1]) testCaseElement.attrib["classname"] = "%s.%s" % (testpath[0] , testpath[1])
testCaseElement.attrib["name"] = "%s %s" % (testpath[2].replace('.','_') , test_mode) testCaseElement.attrib["name"] = "%s %s" % (testpath[2].replace('.','_') , test_mode)
if self.HasUnexpectedOutcome(): if self.HasUnexpectedOutcome():
failureElement = xmlj.Element("failure") failureElement = xmlj.Element("failure")
@ -198,19 +198,19 @@ class TestResult(object):
else: else:
testpackage = testclass testpackage = testclass
return(testpackage,testclass,testcase) return(testpackage,testclass,testcase)
def HasFailed(self): def HasFailed(self):
return self.exit_code != 0 return self.exit_code != 0
def AsyncHasFailed(self): def AsyncHasFailed(self):
return 'Test262:AsyncTestComplete' not in self.stdout return 'Test262:AsyncTestComplete' not in self.stdout
def HasUnexpectedOutcome(self): def HasUnexpectedOutcome(self):
if self.case.IsAsyncTest(): if self.case.IsAsyncTest():
return self.AsyncHasFailed() or self.HasFailed() return self.AsyncHasFailed() or self.HasFailed()
elif self.case.IsNegative(): elif self.case.IsNegative():
return not (self.HasFailed() and self.case.NegativeMatch(self.GetErrorOutput())) return not (self.HasFailed() and self.case.NegativeMatch(self.GetErrorOutput()))
else: else:
return self.HasFailed() return self.HasFailed()
def GetErrorOutput(self): def GetErrorOutput(self):
@ -235,7 +235,7 @@ class TestCase(object):
del testRecord["header"] del testRecord["header"]
testRecord.pop("commentary", None) # do not throw if missing testRecord.pop("commentary", None) # do not throw if missing
self.testRecord = testRecord; self.testRecord = testRecord;
def NegativeMatch(self, stderr): def NegativeMatch(self, stderr):
neg = re.compile(self.GetNegative()) neg = re.compile(self.GetNegative())
return re.search(neg, stderr) return re.search(neg, stderr)
@ -264,8 +264,8 @@ class TestCase(object):
def IsNoStrict(self): def IsNoStrict(self):
return 'noStrict' in self.testRecord return 'noStrict' in self.testRecord
def IsAsyncTest(self): def IsAsyncTest(self):
return '$DONE' in self.test return '$DONE' in self.test
def GetIncludeList(self): def GetIncludeList(self):
if self.testRecord.get('includes'): if self.testRecord.get('includes'):
@ -398,7 +398,7 @@ class TestSuite(object):
self.unmarked_default = unmarked_default self.unmarked_default = unmarked_default
self.print_handle = print_handle self.print_handle = print_handle
self.include_cache = { } self.include_cache = { }
def Validate(self): def Validate(self):
if not path.exists(self.test_root): if not path.exists(self.test_root):
@ -530,7 +530,7 @@ class TestSuite(object):
SkipElement.attrib["message"] = unicode(EXCLUDE_REASON[x].firstChild.nodeValue) SkipElement.attrib["message"] = unicode(EXCLUDE_REASON[x].firstChild.nodeValue)
SkipCaseElement.append(SkipElement) SkipCaseElement.append(SkipElement)
TestSuiteElement.append(SkipCaseElement) TestSuiteElement.append(SkipCaseElement)
for case in cases: for case in cases:
result = case.Run(command_template) result = case.Run(command_template)
if junitfile: if junitfile:
@ -541,7 +541,7 @@ class TestSuite(object):
if logname: if logname:
self.WriteLog(result) self.WriteLog(result)
progress.HasRun(result) progress.HasRun(result)
if print_summary: if print_summary:
self.PrintSummary(progress, logname) self.PrintSummary(progress, logname)
if full_summary: if full_summary:
@ -582,15 +582,15 @@ class TestSuite(object):
includes_dict.update(includes) includes_dict.update(includes)
print includes_dict print includes_dict
def Main(): def Main():
code = 0 code = 0
parser = BuildOptions() parser = BuildOptions()
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
ValidateOptions(options) ValidateOptions(options)
test_suite = TestSuite(options.tests, test_suite = TestSuite(options.tests,
options.strict_only, options.strict_only,
options.non_strict_only, options.non_strict_only,
options.unmarked_default, options.unmarked_default,
options.print_handle) options.print_handle)
@ -616,7 +616,7 @@ def Main():
options.logname, options.logname,
options.junitname) options.junitname)
return code return code
if __name__ == '__main__': if __name__ == '__main__':
try: try:
code = Main() code = Main()