mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Just reformatting to 80 columns
This commit is contained in:
parent
a8625046d2
commit
64db10aa2d
@ -1,14 +1,14 @@
|
||||
/// Copyright (c) 2011 Microsoft Corporation
|
||||
///
|
||||
/// Copyright (c) 2011 Microsoft Corporation
|
||||
///
|
||||
/// Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
/// that the following conditions are met:
|
||||
/// that the following conditions are met:
|
||||
/// * Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
/// the following disclaimer.
|
||||
/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
/// the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
/// the following disclaimer.
|
||||
/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
/// the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
/// * Neither the name of Microsoft nor the names of its contributors may be used to
|
||||
/// endorse or promote products derived from this software without specific prior written permission.
|
||||
///
|
||||
///
|
||||
/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||
/// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
/// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
@ -16,40 +16,68 @@
|
||||
/// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
/// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
/// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//Global Scope Test Case Validator
|
||||
|
||||
//An exception is expected
|
||||
if (testDescrip.negative !== undefined) {
|
||||
//TODO - come up with a generic way of catching the error type from this.onerror
|
||||
//TODO - come up with a generic way of catching the error type
|
||||
//from this.onerror
|
||||
testDescrip.negative = testDescrip.negative === "NotEarlyError" ?
|
||||
testDescrip.negative : (testDescrip.negative === "^((?!NotEarlyError).)*$" ?
|
||||
testDescrip.negative : ".");
|
||||
testDescrip.negative :
|
||||
(testDescrip.negative === "^((?!NotEarlyError).)*$" ?
|
||||
testDescrip.negative : ".");
|
||||
if (this.iframeError === undefined) { //no exception was thrown
|
||||
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
|
||||
'fail',
|
||||
Error('No exception was thrown; expected an error "message" property matching the regular expression "' + testDescrip.negative + '".'));
|
||||
} else if (!(new RegExp(testDescrip.negative, "i").test(this.iframeError))) { //wrong type of exception thrown
|
||||
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
|
||||
'fail',
|
||||
Error('Expected an exception with a "message" property matching the regular expression "' + testDescrip.negative +'" to be thrown; actual was "' + this.iframeError + '".'));
|
||||
testRun(testDescrip.id,
|
||||
testDescrip.path,
|
||||
testDescrip.description,
|
||||
testDescrip.code,
|
||||
'fail',
|
||||
Error('No exception was thrown; expected an error "message"' +
|
||||
' property matching the regular expression "' +
|
||||
testDescrip.negative + '".'));
|
||||
} else if (!(new RegExp(testDescrip.negative,
|
||||
"i").test(this.iframeError))) {
|
||||
//wrong type of exception thrown
|
||||
testRun(testDescrip.id,
|
||||
testDescrip.path,
|
||||
testDescrip.description,
|
||||
testDescrip.code,
|
||||
'fail',
|
||||
Error('Expected an exception with a "message"' +
|
||||
' property matching the regular expression "' +
|
||||
testDescrip.negative +
|
||||
'" to be thrown; actual was "' +
|
||||
this.iframeError + '".'));
|
||||
} else {
|
||||
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
|
||||
'pass', undefined);
|
||||
testRun(testDescrip.id,
|
||||
testDescrip.path,
|
||||
testDescrip.description,
|
||||
testDescrip.code,
|
||||
'pass',
|
||||
undefined);
|
||||
}
|
||||
}
|
||||
|
||||
//Exception was not expected to be thrown
|
||||
else if (this.iframeError !== undefined) {
|
||||
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
|
||||
'fail',
|
||||
Error('Unexpected exception, "' + this.iframeError + '" was thrown.'));
|
||||
}
|
||||
else if (this.iframeError !== undefined) {
|
||||
testRun(testDescrip.id,
|
||||
testDescrip.path,
|
||||
testDescrip.description,
|
||||
testDescrip.code,
|
||||
'fail',
|
||||
Error('Unexpected exception, "' +
|
||||
this.iframeError + '" was thrown.'));
|
||||
}
|
||||
|
||||
else {
|
||||
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
|
||||
'pass', undefined);
|
||||
testRun(testDescrip.id,
|
||||
testDescrip.path,
|
||||
testDescrip.description,
|
||||
testDescrip.code,
|
||||
'pass',
|
||||
undefined);
|
||||
}
|
||||
|
||||
testFinished();
|
@ -42,17 +42,19 @@ from packagerConfig import *
|
||||
|
||||
#--Globals---------------------------------------------------------------------
|
||||
|
||||
__parser = argparse.ArgumentParser(description='Tool used to generate the test262 website')
|
||||
__parser = argparse.ArgumentParser(description= \
|
||||
'Tool used to generate the test262 website')
|
||||
__parser.add_argument('version', action='store',
|
||||
help='Version of the test suite.')
|
||||
help='Version of the test suite.')
|
||||
__parser.add_argument('--type', action='store', default='test262',
|
||||
help='Type of test case runner to generate.')
|
||||
help='Type of test case runner to generate.')
|
||||
__parser.add_argument('--console', action='store_true', default=False,
|
||||
help='Type of test case runner to generate.')
|
||||
help='Type of test case runner to generate.')
|
||||
ARGS = __parser.parse_args()
|
||||
|
||||
if not os.path.exists(EXCLUDED_FILENAME):
|
||||
print "Cannot generate (JSON) test262 tests without a file, %s, showing which tests have been disabled!" % EXCLUDED_FILENAME
|
||||
print "Cannot generate (JSON) test262 tests without a file," + \
|
||||
" %s, showing which tests have been disabled!" % EXCLUDED_FILENAME
|
||||
sys.exit(1)
|
||||
EXCLUDE_LIST = xml.dom.minidom.parse(EXCLUDED_FILENAME)
|
||||
EXCLUDE_LIST = EXCLUDE_LIST.getElementsByTagName("test")
|
||||
@ -105,7 +107,8 @@ def createDepDirs(dirName):
|
||||
os.mkdir(dirName)
|
||||
|
||||
def test262PathToConsoleFile(path):
|
||||
stuff = os.path.join(TEST262_CONSOLE_CASES_DIR, path.replace("/", os.path.sep))
|
||||
stuff = os.path.join(TEST262_CONSOLE_CASES_DIR,
|
||||
path.replace("/", os.path.sep))
|
||||
createDepDirs(os.path.dirname(stuff))
|
||||
return stuff
|
||||
|
||||
@ -133,7 +136,8 @@ def dirWalker(dirName):
|
||||
'''
|
||||
global TEST_SUITE_SECTIONS
|
||||
#First check to see if it has test files directly inside it
|
||||
temp = [os.path.join(dirName, x) for x in os.listdir(dirName) if not os.path.isdir(os.path.join(dirName, x))]
|
||||
temp = [os.path.join(dirName, x) for x in os.listdir(dirName) \
|
||||
if not os.path.isdir(os.path.join(dirName, x))]
|
||||
if len(temp)!=0:
|
||||
TEST_SUITE_SECTIONS.append(dirName)
|
||||
return
|
||||
@ -171,7 +175,8 @@ def isTestStarted(line):
|
||||
elif "/*" in line: #Beginning of a newline comment
|
||||
IS_MULTILINE_COMMENT = True
|
||||
return False
|
||||
elif IS_MULTILINE_COMMENT: #//we're already in a multi-line comment that hasn't ended
|
||||
elif IS_MULTILINE_COMMENT: #//we're already in a multi-line
|
||||
#comment that hasn't ended
|
||||
return False
|
||||
elif re.match("^\s*//", line)!=None: #//blah
|
||||
return False
|
||||
@ -221,7 +226,8 @@ for chapter in TEST_SUITE_SECTIONS:
|
||||
testCount = 0
|
||||
for test in sourceFiles:
|
||||
#TODO - use something other than the hard-coded 'TestCases' below
|
||||
testPath = "TestCases" + test.split(TEST262_CASES_DIR, 1)[1].replace("\\", "/")
|
||||
testPath = "TestCases" + \
|
||||
test.split(TEST262_CASES_DIR, 1)[1].replace("\\", "/")
|
||||
testName=test.rsplit(".", 1)[0]
|
||||
testName=testName.rsplit(os.path.sep, 1)[1]
|
||||
if EXCLUDE_LIST.count(testName)==0:
|
||||
@ -233,7 +239,8 @@ for chapter in TEST_SUITE_SECTIONS:
|
||||
scriptCode = tempFile.readlines()
|
||||
tempFile.close()
|
||||
scriptCodeContent=""
|
||||
#Rip out license headers that add unnecessary bytes to the JSON'ized test cases
|
||||
#Rip out license headers that add unnecessary bytes to
|
||||
#the JSON'ized test cases
|
||||
inBeginning = True
|
||||
IS_MULTILINE_COMMENT = False
|
||||
|
||||
@ -246,7 +253,8 @@ for chapter in TEST_SUITE_SECTIONS:
|
||||
scriptCodeContent += line
|
||||
|
||||
if scriptCodeContent=="":
|
||||
print "WARNING (" + test + "): unable to strip comments/license header/etc."
|
||||
print "WARNING (" + test + \
|
||||
"): unable to strip comments/license header/etc."
|
||||
scriptCodeContent = "".join(scriptCode)
|
||||
scriptCodeContentB64 = base64.b64encode(scriptCodeContent)
|
||||
|
||||
@ -265,9 +273,12 @@ for chapter in TEST_SUITE_SECTIONS:
|
||||
tests.append(testDict)
|
||||
|
||||
if ARGS.console:
|
||||
with open(test262PathToConsoleFile(testDict["path"]), "w") as fConsole:
|
||||
with open(test262PathToConsoleFile(testDict["path"]),
|
||||
"w") as fConsole:
|
||||
fConsole.write(scriptCodeContent)
|
||||
with open(test262PathToConsoleFile(testDict["path"][:-3] + "_metadata.js"), "w") as fConsoleMeta:
|
||||
with open(test262PathToConsoleFile(testDict["path"][:-3] + \
|
||||
"_metadata.js"),
|
||||
"w") as fConsoleMeta:
|
||||
metaDict = testDict.copy()
|
||||
del metaDict["code"]
|
||||
fConsoleMeta.write("testDescrip = " + str(metaDict))
|
||||
@ -283,7 +294,8 @@ for chapter in TEST_SUITE_SECTIONS:
|
||||
|
||||
#create a node for the tests and add it to our testsLists
|
||||
testsList["testsCollection"] = sect
|
||||
with open(os.path.join(TEST262_WEB_CASES_DIR, chapterName + ".json"), "w") as f:
|
||||
with open(os.path.join(TEST262_WEB_CASES_DIR, chapterName + ".json"),
|
||||
"w") as f:
|
||||
json.dump(testsList, f, separators=(',',':'), sort_keys=True)
|
||||
|
||||
|
||||
@ -291,11 +303,17 @@ for chapter in TEST_SUITE_SECTIONS:
|
||||
CHAPTER_TEST_CASES_JSON = {}
|
||||
CHAPTER_TEST_CASES_JSON["numTests"] = int(sect["numTests"])
|
||||
CHAPTER_TEST_CASES_JSON["version"] = ARGS.version
|
||||
CHAPTER_TEST_CASES_JSON["date"] = str(datetime.datetime.now().date())
|
||||
CHAPTER_TEST_CASES_JSON["testSuite"] = [WEBSITE_CASES_PATH + chapterName + ".json"]
|
||||
with open(os.path.join(TEST262_WEB_CASES_DIR, "testcases_%s.json" % chapterName), "w") as f:
|
||||
json.dump(CHAPTER_TEST_CASES_JSON, f, separators=(',',':'), sort_keys=True)
|
||||
generateHarness(ARGS.type, "testcases_%s.json" % chapterName, chapterName.replace("chapter", "Chapter "))
|
||||
CHAPTER_TEST_CASES_JSON["date"] = \
|
||||
str(datetime.datetime.now().date())
|
||||
CHAPTER_TEST_CASES_JSON["testSuite"] = \
|
||||
[WEBSITE_CASES_PATH + chapterName + ".json"]
|
||||
with open(os.path.join(TEST262_WEB_CASES_DIR,
|
||||
"testcases_%s.json" % chapterName),
|
||||
"w") as f:
|
||||
json.dump(CHAPTER_TEST_CASES_JSON, f, separators=(',',':'),
|
||||
sort_keys=True)
|
||||
generateHarness(ARGS.type, "testcases_%s.json" % chapterName,
|
||||
chapterName.replace("chapter", "Chapter "))
|
||||
|
||||
#add the name of the chapter test to our complete list
|
||||
SECTIONS_LIST.append(WEBSITE_CASES_PATH + chapterName + ".json")
|
||||
@ -317,10 +335,12 @@ generateHarness(ARGS.type, "default.json", "Chapters 1-16")
|
||||
print ""
|
||||
print "Deploying test harness files to 'TEST262_WEB_HARNESS_DIR'..."
|
||||
if TEST262_HARNESS_DIR!=TEST262_WEB_HARNESS_DIR:
|
||||
for filename in [x for x in os.listdir(TEST262_HARNESS_DIR) if x.endswith(".js")]:
|
||||
for filename in [x for x in os.listdir(TEST262_HARNESS_DIR) \
|
||||
if x.endswith(".js")]:
|
||||
toFilenameList = [ os.path.join(TEST262_WEB_HARNESS_DIR, filename)]
|
||||
if ARGS.console:
|
||||
toFilenameList.append(os.path.join(TEST262_CONSOLE_HARNESS_DIR, filename))
|
||||
toFilenameList.append(os.path.join(TEST262_CONSOLE_HARNESS_DIR,
|
||||
filename))
|
||||
|
||||
for toFilename in toFilenameList:
|
||||
if not os.path.exists(os.path.dirname(toFilename)):
|
||||
|
@ -31,30 +31,38 @@ WEBSITE_SHORT_NAME = "website"
|
||||
CONSOLE_SHORT_NAME = "console"
|
||||
|
||||
#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)
|
||||
|
||||
#Directory full of test cases we want to port to the website's test harness runner
|
||||
#Directory full of test cases we want to port to the website's test
|
||||
#harness runner
|
||||
TEST262_CASES_DIR = os.path.join(TEST262_ROOT, "test", "suite")
|
||||
|
||||
#Directory containing test harness files to be ported over to the website. Note that
|
||||
#only *.js files will be migrated from this dir.
|
||||
#Directory containing test harness files to be ported over to the
|
||||
#website. Note that only *.js files will be migrated from this dir.
|
||||
TEST262_HARNESS_DIR = os.path.join(TEST262_ROOT, "test", "harness")
|
||||
|
||||
#Directory full of website test cases (ported over from TEST262_CASES_DIR)
|
||||
TEST262_WEB_CASES_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, "json")
|
||||
TEST262_CONSOLE_CASES_DIR = os.path.join(TEST262_ROOT, CONSOLE_SHORT_NAME)
|
||||
|
||||
#Directory containing the website's test harness (ported over from TEST262_HARNESS_DIR)
|
||||
TEST262_WEB_HARNESS_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, "harness")
|
||||
TEST262_CONSOLE_HARNESS_DIR = os.path.join(TEST262_ROOT, CONSOLE_SHORT_NAME, "harness")
|
||||
#Directory containing the website's test harness (ported over from
|
||||
#TEST262_HARNESS_DIR)
|
||||
TEST262_WEB_HARNESS_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME,
|
||||
"harness")
|
||||
TEST262_CONSOLE_HARNESS_DIR = os.path.join(TEST262_ROOT, CONSOLE_SHORT_NAME,
|
||||
"harness")
|
||||
|
||||
#Path to the ported test case files on the actual website as opposed to the Hg layout
|
||||
#Path to the ported test case files on the actual website as opposed
|
||||
#to the Hg layout
|
||||
WEBSITE_CASES_PATH = "json/"
|
||||
|
||||
#The name of a file which contains a list of tests which should be disabled in test262.
|
||||
#These tests are either invalid as-per ES5 or have issues with the test262 web harness.
|
||||
EXCLUDED_FILENAME = os.path.join(TEST262_ROOT, "test", "config", "excludelist.xml")
|
||||
#The name of a file which contains a list of tests which should be
|
||||
#disabled in test262. These tests are either invalid as-per ES5 or
|
||||
#have issues with the test262 web harness.
|
||||
EXCLUDED_FILENAME = os.path.join(TEST262_ROOT, "test", "config",
|
||||
"excludelist.xml")
|
||||
|
||||
WEBSITE_EXCLUDE_RE_LIST = ["bestPractice"]
|
||||
WEBSITE_EXCLUDE_RE_LIST = [ re.compile(x) for x in WEBSITE_EXCLUDE_RE_LIST]
|
||||
@ -70,9 +78,11 @@ def generateHarness(harnessType, jsonName, title):
|
||||
if TEMPLATE_LINES==None or harnessType!=__lastHarnessType:
|
||||
__lastHarnessType = harnessType
|
||||
TEMPLATE_LINES = []
|
||||
with open(os.path.join(os.getcwd(), "templates","runner." + harnessType + ".html"), "r") as f:
|
||||
with open(os.path.join(os.getcwd(), "templates",
|
||||
"runner." + harnessType + ".html"), "r") as f:
|
||||
TEMPLATE_LINES = f.readlines()
|
||||
fileName = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, jsonName.replace(".json", ".html"))
|
||||
fileName = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME,
|
||||
jsonName.replace(".json", ".html"))
|
||||
fileNameExists = False
|
||||
if os.path.exists(fileName):
|
||||
SC_HELPER.edit(fileName)
|
||||
@ -80,9 +90,11 @@ def generateHarness(harnessType, jsonName, title):
|
||||
with open(fileName, "w") as f:
|
||||
for line in TEMPLATE_LINES:
|
||||
if "var TEST_LIST_PATH =" in line:
|
||||
f.write(" var TEST_LIST_PATH = \"json/" + jsonName + "\";" + os.linesep)
|
||||
f.write(" var TEST_LIST_PATH = \"json/" + jsonName + \
|
||||
"\";" + os.linesep)
|
||||
#elif "ECMAScript 5" in line:
|
||||
# f.write(line.replace("ECMAScript 5", "ECMAScript 5: %s" % title))
|
||||
# f.write(line.replace("ECMAScript 5",
|
||||
# "ECMAScript 5: %s" % title))
|
||||
else:
|
||||
f.write(line)
|
||||
if not fileNameExists:
|
||||
@ -109,4 +121,4 @@ class SCAbstraction(object):
|
||||
'''
|
||||
subprocess.call(["hg", "add", filename])
|
||||
|
||||
SC_HELPER = SCAbstraction()
|
||||
SC_HELPER = SCAbstraction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user