From ff32b5c3fc76e3cff33919f8921ed61e889bd03e Mon Sep 17 00:00:00 2001 From: David Fugate Date: Sat, 24 Sep 2011 10:35:50 -0700 Subject: [PATCH 1/3] New HTML+console packager. --- tools/packaging/TestCasePackagerConfig.py | 110 +++++++ tools/packaging/packager.py | 308 ++++++++++++++++++ tools/packaging/templates/runner.test262.html | 170 ++++++++++ 3 files changed, 588 insertions(+) create mode 100644 tools/packaging/TestCasePackagerConfig.py create mode 100644 tools/packaging/packager.py create mode 100644 tools/packaging/templates/runner.test262.html diff --git a/tools/packaging/TestCasePackagerConfig.py b/tools/packaging/TestCasePackagerConfig.py new file mode 100644 index 0000000000..9364556d70 --- /dev/null +++ b/tools/packaging/TestCasePackagerConfig.py @@ -0,0 +1,110 @@ +# Copyright (c) 2009 Microsoft Corporation +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided +# 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. +# * 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 +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# 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. + +#--Imports--------------------------------------------------------------------- +import os +import subprocess +import stat + +#--Globals--------------------------------------------------------------------- +MAX_CASES_PER_JSON = 1000 + +#Directories under "test\suite\" containing ES5 test chapter directories +#with *.js tests underneath them +TEST_CONTRIB_DIRS = ["sputnik_converted", "ietestcenter"] + +#Global scope source files found directly under "test\suite\". +GLOBAL_SCOPE_FILES = ["SputnikGlobalScope.js", "IETCGlobalScope.js"] + +#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.abspath(TEST262_ROOT) + +#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. +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", "resources", "scripts", "testcases") + +#Directory containing the website's test harness (ported over from TEST262_HARNESS_DIR) +TEST262_WEB_HARNESS_DIR = os.path.join(TEST262_ROOT, "website", "resources", "scripts", "global") + +#Path to the ported test case files on the actual website as opposed to the Hg layout +WEBSITE_CASES_PATH = "resources/scripts/testcases/" + +#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") + +#------------------------------------------------------------------------------ + +TEMPLATE_LINES = None +__lastHarnessType = None + +def generateHarness(harnessType, jsonName, title): + global TEMPLATE_LINES + global __lastHarnessType + 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: + TEMPLATE_LINES = f.readlines() + fileName = os.path.join(TEST262_ROOT, "website", jsonName.replace(".json", ".html")) + fileNameExists = False + if os.path.exists(fileName): + SC_HELPER.edit(fileName) + fileNameExists = True + with open(fileName, "w") as f: + for line in TEMPLATE_LINES: + if "var TEST_LIST_PATH =" in line: + f.write(" var TEST_LIST_PATH = \"resources/scripts/testcases/" + jsonName + "\";" + os.linesep) + #elif "ECMAScript 5" in line: + # f.write(line.replace("ECMAScript 5", "ECMAScript 5: %s" % title)) + else: + f.write(line) + if not fileNameExists: + SC_HELPER.add(fileName) + +#------------------------------------------------------------------------------ +class SCAbstraction(object): + ''' + A class which abstracts working with source control systems in relation to + generated test262 files. Useful when test262 is also used internally by + browser implementors. + ''' + def edit(self, filename): + ''' + Source control edit of a file. For Mercurial, just make sure it's + writable. + ''' + if not(os.stat(filename).st_mode & stat.S_IWRITE): + os.chmod(filename, stat.S_IWRITE) + + def add(self, filename): + ''' + Source control add of a file. + ''' + subprocess.call(["hg", "add", filename]) + +SC_HELPER = SCAbstraction() \ No newline at end of file diff --git a/tools/packaging/packager.py b/tools/packaging/packager.py new file mode 100644 index 0000000000..7c7a02d145 --- /dev/null +++ b/tools/packaging/packager.py @@ -0,0 +1,308 @@ +# Copyright (c) 2009 Microsoft Corporation +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided +# 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. +# * 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 +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# 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. + +#--Imports--------------------------------------------------------------------- +import argparse +import os +import sys +import xml.dom.minidom +import base64 +import datetime +import shutil +import re +import json +import stat + +#--Stubs----------------------------------------------------------------------- +def generateHarness(harnessType, jsonFile, description): + pass + + +#------------------------------------------------------------------------------ +from TestCasePackagerConfig import * + +#--Globals--------------------------------------------------------------------- + +__parser = argparse.ArgumentParser(description='Tool used to generate the test262 website') +__parser.add_argument('version', action='store', + help='Version of the test suite.') +__parser.add_argument('--type', action='store', default='test262', + 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 + sys.exit(1) +EXCLUDE_LIST = xml.dom.minidom.parse(EXCLUDED_FILENAME) +EXCLUDE_LIST = EXCLUDE_LIST.getElementsByTagName("test") +EXCLUDE_LIST = [x.getAttribute("id") for x in EXCLUDE_LIST] + +#a list of all ES5 test chapter directories +TEST_SUITE_SECTIONS = [] + +#total number of tests accross the entire set of tests. +TOTAL_TEST_COUNT = 0 + +#global which states whether the test case we're currently processing is in +#the midst of a "/* ... */" style comment +IS_MULTILINE_COMMENT = False + +#List of all *.json files containing encoded test cases +SECTIONS_LIST = [] + +ONE_JSON_PER_CHAPTER = False +TESTCASELIST_PER_JSON = False + +#--Sanity checks--------------------------------------------------------------# +if not os.path.exists(TEST262_CASES_DIR): + print "Cannot generate (JSON) test262 tests when the path containing said tests, %s, does not exist!" % TEST262_CASES_DIR + sys.exit(1) + +if not os.path.exists(TEST262_HARNESS_DIR): + print "Cannot copy the test harness from a path, %s, that does not exist!" % TEST262_HARNESS_DIR + sys.exit(1) + +if not os.path.exists(TEST262_WEB_CASES_DIR): + os.mkdir(TEST262_WEB_CASES_DIR) + +if not os.path.exists(TEST262_WEB_HARNESS_DIR): + os.mkdir(TEST262_WEB_HARNESS_DIR) + +if not hasattr(ARGS, "version"): + print "A test262 suite version must be specified from the command-line to run this script!" + sys.exit(1) + +#--Helpers--------------------------------------------------------------------# +def getJSCount(dirName): + ''' + Returns the total number of *.js files (recursively) under a given + directory, dirName. + ''' + retVal = 0 + if os.path.isfile(dirName) and dirName.endswith(".js"): + retVal = 1 + elif os.path.isdir(dirName): + tempList = [os.path.join(dirName, x) for x in os.listdir(dirName)] + for x in tempList: + retVal += getJSCount(x) + #else: + # raise Exception("getJSCount: encountered a non-file/non-dir!") + return retVal + +#------------------------------------------------------------------------------ +def dirWalker(dirName): + ''' + Populates TEST_SUITE_SECTIONS with ES5 test directories based + upon the number of test files per directory. + ''' + 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))] + if len(temp)!=0: + TEST_SUITE_SECTIONS.append(dirName) + return + + #Next check to see if all *.js files under this directory exceed our max + #for a JSON file + temp = getJSCount(dirName) + if temp==0: + print "ERROR: expected there to be JavaScript tests under dirName!" + sys.exit(1) + elif temp < MAX_CASES_PER_JSON: + TEST_SUITE_SECTIONS.append(dirName) + return + else: + #Max has been exceeded. We need to look at each subdir individually + temp = os.listdir(dirName) + for tempSubdir in temp: + dirWalker(os.path.join(dirName, tempSubdir)) + +#------------------------------------------------------------------------------ +def isTestStarted(line): + ''' + 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 + line. However, we know for a fact this is not the case in IE Test Center + or Sputnik tests. + ''' + global IS_MULTILINE_COMMENT + + if IS_MULTILINE_COMMENT and ("*/" in line): #End of a newline comment + IS_MULTILINE_COMMENT = False + return False + 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 + return False + elif re.match("^\s*//", line)!=None: #//blah + return False + elif re.match("^\s*$", line)!=None: #newlines + return False + elif "ES5Harness" in line: #definitely start of the test! + return True + return True + +#------------------------------------------------------------------------------ +def getAllJSFiles(dirName): + retVal = [] + for fullPath,dontCare,files in os.walk(dirName): + retVal += [os.path.join(fullPath,b) for b in files if b.endswith(".js")] + return retVal + +#--MAIN------------------------------------------------------------------------ +for temp in TEST_CONTRIB_DIRS: + temp = os.path.join(TEST262_CASES_DIR, temp) + if not os.path.exists(temp): + print "The expected ES5 test directory,", temp, "did not exist!" + sys.exit(1) + + if not ONE_JSON_PER_CHAPTER: + dirWalker(temp) + else: + for tempSubdir in os.listdir(temp): + TEST_SUITE_SECTIONS.append(os.path.join(temp, tempSubdir)) + + +for chapter in TEST_SUITE_SECTIONS: + chapterName = chapter.rsplit(os.path.sep, 1)[1] + print "Generating test cases for ES5 chapter:", chapterName + #create dictionaries for all our tests and a section + testsList = {} + sect = {} + sect["name"] = "Chapter - " + chapterName + + #create an array for tests in a chapter + tests = [] + sourceFiles = getAllJSFiles(chapter) + + if len(sourceFiles)!=0: + excluded = 0 + 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("\\", "/") + testName=test.rsplit(".", 1)[0] + testName=testName.rsplit(os.path.sep, 1)[1] + if EXCLUDE_LIST.count(testName)==0: + # dictionary for each test + testDict = {} + testDict["id"] = testName + testDict["path"] = testPath.replace("/ietestcenter", "").replace("/sputnik_converted", "") + + tempFile = open(test, "r") + scriptCode = tempFile.readlines() + tempFile.close() + scriptCodeContent="" + #Rip out license headers that add unnecessary bytes to the JSON'ized test cases + inBeginning = True + IS_MULTILINE_COMMENT = False + + for line in scriptCode: + if inBeginning: + isStarted = isTestStarted(line) + if not isStarted: + continue + inBeginning = False + scriptCodeContent += line + + if scriptCodeContent=="": + print "WARNING (" + test + "): unable to strip comments/license header/etc." + scriptCodeContent = "".join(scriptCode) + scriptCodeContent = base64.b64encode(scriptCodeContent) + + #add the test encoded code node to our test dictionary + testDict["code"] = scriptCodeContent + #now close the dictionary for the test + + #this adds the test to our tests array + tests.append(testDict) + testCount += 1 + else: + print "Excluded:", testName + excluded = excluded + 1 + + #we have completed our tests + # add section node, number of tests and the tests themselves. + sect["numTests"] = str(len(sourceFiles)-excluded) + sect["tests"] = tests + + #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: + json.dump(testsList, f, separators=(',',':'), sort_keys=True) + + + if TESTCASELIST_PER_JSON: + 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 ")) + + #add the name of the chapter test to our complete list + SECTIONS_LIST.append(WEBSITE_CASES_PATH + chapterName + ".json") + TOTAL_TEST_COUNT += int(sect["numTests"]) + + +#we now have the list of files for each chapter +#create a root node for our suite +TEST_CASES_JSON = {} +TEST_CASES_JSON["numTests"] = TOTAL_TEST_COUNT +TEST_CASES_JSON["version"] = ARGS.version +TEST_CASES_JSON["date"] = str(datetime.datetime.now().date()) +TEST_CASES_JSON["testSuite"] = SECTIONS_LIST +with open(os.path.join(TEST262_WEB_CASES_DIR, "default.json"), "w") as f: + json.dump(TEST_CASES_JSON, f, separators=(',',':'), sort_keys=True) +generateHarness(ARGS.type, "default.json", "Chapters 1-16") + +#Deploy test harness to website as well +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")]: + toFilename = os.path.join(TEST262_WEB_HARNESS_DIR, filename) + fileExists = os.path.exists(toFilename) + if fileExists: + SC_HELPER.edit(toFilename) + shutil.copy(os.path.join(TEST262_HARNESS_DIR, filename), + toFilename) + if not fileExists: + SC_HELPER.add(toFilename) + +#Copying the global scope files over as well +#TODO: really the HTML harness file should be generated as well... +print "" +print "Deploying global scope metadata files to 'TEST262_WEB_HARNESS_DIR'..." +for gsf in GLOBAL_SCOPE_FILES: + toFilename = os.path.join(TEST262_WEB_CASES_DIR, gsf) + fileExists = os.path.exists(toFilename) + if fileExists: + SC_HELPER.edit(toFilename) + shutil.copy(os.path.join(TEST262_CASES_DIR, gsf), + toFilename) + if not fileExists: + SC_HELPER.add(toFilename) + +print "Done." diff --git a/tools/packaging/templates/runner.test262.html b/tools/packaging/templates/runner.test262.html new file mode 100644 index 0000000000..3bfea29f25 --- /dev/null +++ b/tools/packaging/templates/runner.test262.html @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + +ECMAScript Test262 + + + +
+ +
+
+
+ Loading... + Loading... +
+
+
+ +
+ +
+
+ +
+ + +
+ +
+

What is test262?

+

test262 is a test suite intended to check agreement between JavaScript implementations and the ECMA-262 Specification (currently 5th Edition). The test suite contains thousands of individual tests, each of which tests some specific requirements of the ECMAScript specification.

+

What is ECMAScript?

+

"ECMAScript" is the name under which the language more commonly known as "JavaScript" is standardized. Development of the ECMAScript standard is the responsibility of Technical Committee 39 (TC39) of Ecma International. The ECMAScript standard is officially known as ECMA-262. ECMAScript 5 (or just ES5) is short hand for the "ECMA-262, 5th Edition ECMAScript Language Specification" the official name of the current edition of the standard. ECMAScript 5 was approved as an official Ecma standard by the Ecma General Assembly on December 3, 2009. The ECMAScript 5 Specification (PDF) is available from the Ecma International web site.

+

Who creates and maintains test262?

+

Development of test262 is a project of Ecma TC39. The testing framework and individual tests are created by member organizations of TC39 and contributed to Ecma for use in test262. For more information about how test262 is developed and maintained click the “Development” tab at the top of this page.

+

What is the status of test262?

+

test262 is not yet complete. It is still undergoing active development. Some portions of the ES5 specification have very complete test coverage while other portions of the specification have only partial test coverage. Some tests may be invalid or may yield false positive or false negative results. A perfect passing score on test262 does not guarantee that a JavaScript implementation perfectly supports ES5. Because tests are being actively added and modified, tests results from different days or times may not be directly comparable. Click the “Development” tab at the top of this page for instructions for reporting test262 bugs.

+

Where can I found out more?

+

Please visit our Frequently Asked Questions section on the ECMAScript Wiki.

+ +

Running the Tests

+

Click the “Run” tab at the top of this page for instructions and follow the instructions to run the tests.

+ + + +
+ +
+

Development

+

Test262 is being developed by the members of Ecma TC39. Ecma's intellectual property policies, permit only Ecma + members to directly contribute code to the project. However, a public mailing list is used to coordinate development of Test262. If you wish to participate in the discussion please subscribe. Bug reports and suggestions should be sent to the mailing list. +

+

+ Ecma members can find detailed instructions on Test262 development procedures at the Test262 Wiki. +

+
+ +
+ +

Please click on the Start button to start the test. Once you start the test you may pause the test anytime by clicking on the Pause button. You can click on the Results tab once the test is completed or after pausing the test. The Reset button is for restarting the test run.

+ + +
+
+
+   +
+
+
+

> + Timer Value(ms) : +

+ +
+ + Tests To Run:  | + Total Tests Ran: | Pass: | Fail: + | Failed To Load: +

+
+ +
+
+
+
+ Test Suite Ver.:  | Test Suite Date: +
+
+ +
+
+
+ +
+
+
Total Tests:
+ Passed: | Failed: | + Failed To Load: +
+ +
+
+
Test results will be displayed after the tests are executed using the Run page.
+
+
+ Test Suite Ver.:  | Test Suite Date: +
+ +
+  100%  +  75% to 99.9%  +  50% to 75%   +  less than 50% +
+
+
+
+ + + + + From 5be3b44a3d637dd980985363ec0daa0c745bb1e4 Mon Sep 17 00:00:00 2001 From: David Fugate Date: Sat, 24 Sep 2011 11:46:26 -0700 Subject: [PATCH 2/3] Removed all traces of test pre-req requirements. Generate the 'id' property from the 'path' property. --- test/harness/gs.js | 10 ++++----- test/harness/helper.js | 5 ----- test/harness/sta.js | 50 +++++++++++++++++------------------------- test/harness/sth.js | 21 +++++++++++++++--- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/test/harness/gs.js b/test/harness/gs.js index bd57897c94..6916a1fd9c 100644 --- a/test/harness/gs.js +++ b/test/harness/gs.js @@ -23,28 +23,28 @@ //An exception is expected if (testDescrip.negative !== undefined) { if (window.iframeError === undefined) { //no exception was thrown - testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', + 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(window.iframeError))) { //wrong type of exception thrown - testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', + 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 "' + window.iframeError + '".')); } else { - testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', + testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, 'pass', undefined); } } //Exception was not expected to be thrown else if (window.iframeError !== undefined) { - testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', + testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, 'fail', Error('Unexpected exception, "' + window.iframeError + '" was thrown.')); } else { - testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, typeof testDescrip.precondition !== 'undefined' ? testDescrip.precondition.toString() : '', + testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, 'pass', undefined); } diff --git a/test/harness/helper.js b/test/harness/helper.js index adf96c02db..709c4f155d 100644 --- a/test/harness/helper.js +++ b/test/harness/helper.js @@ -160,11 +160,6 @@ function Presenter() { innerHTML += '


Testcase'; innerHTML += '
' + test.code + '
'; - if (test.pre) { - innerHTML += 'Precondition'; - innerHTML += '
' + test.pre + '
'; - } - innerHTML += 'Path'; innerHTML += '
' + test.path + ' 
 '; diff --git a/test/harness/sta.js b/test/harness/sta.js index b76c26d44f..97c971f01c 100644 --- a/test/harness/sta.js +++ b/test/harness/sta.js @@ -288,38 +288,28 @@ var NotEarlyError = new Error(NotEarlyErrorString); var ES5Harness = {}; ES5Harness.registerTest = function (test) { var error; - //Has a test precondition set, but the precondition fails - if (test.precondition && !test.precondition()) { - testRun(test.id, test.path, test.description, test.test.toString(), - typeof test.precondition !== 'undefined' ? test.precondition.toString() : '', - 'fail', Error('Precondition Failed')); - } - //We're good to actually run the test case - else { - try { - if (test.strict!==undefined) { - var res = test.test(); - } else { - var res = test.test.call(window); - } + try { + if (test.strict!==undefined) { + var res = test.test(); + } else { + var res = test.test.call(window); + } - } catch (e) { - res = 'fail'; - error = e; - if (!(e instanceof Error)) { - try { - error = Error(e.toString()); - } catch (e2) { - error = Error("test262: unknown error in test case or ECMAScript implementation"); - } + } catch (e) { + res = 'fail'; + error = e; + if (!(e instanceof Error)) { + try { + error = Error(e.toString()); + } catch (e2) { + error = Error("test262: unknown error in test case or ECMAScript implementation"); } } - //Sputnik and IE Test Center tests are a bit different in terms of return values. - //That is, IE Test Center will always return 'true' IFF the test passed. Sputnik - //test cases will return either 'true' or 'undefined' if they pass. - var retVal = /^s/i.test(test.id) ? (res === true || typeof res === 'undefined' ? 'pass' : 'fail') : (res === true ? 'pass' : 'fail'); - testRun(test.id, test.path, test.description, test.test.toString(), - typeof test.precondition !== 'undefined' ? test.precondition.toString() : '', - retVal, error); } + //Sputnik and IE Test Center tests are a bit different in terms of return values. + //That is, IE Test Center will always return 'true' IFF the test passed. Sputnik + //test cases will return either 'true' or 'undefined' if they pass. + var retVal = /^s/i.test(test.id) ? (res === true || typeof res === 'undefined' ? 'pass' : 'fail') : (res === true ? 'pass' : 'fail'); + testRun(test.id, test.path, test.description, test.test.toString(), + retVal, error); } diff --git a/test/harness/sth.js b/test/harness/sth.js index 4df798a36c..50d6adabf3 100644 --- a/test/harness/sth.js +++ b/test/harness/sth.js @@ -87,14 +87,13 @@ function BrowserRunner() { } /* Called from the child window after the test has run. */ - function testRun(id, path, description, codeString, preconditionString, result, error) { + function testRun(id, path, description, codeString, result, error) { currentTest.id = id; currentTest.path = path; currentTest.description = description; currentTest.result = result; currentTest.error = error; currentTest.code = codeString; - currentTest.pre = preconditionString; } @@ -279,6 +278,21 @@ function TestLoader() { }}); } + this.getIdFromPath = function(path) { + //path is of the form "a/b/c.js" + + var id = path.split("/"); + //id is now of the form ["a", "b", "c.js"]; + + id = id[id.length-1]; + //id is now of the form "c.js" + + id = id.replace(/\.js$/i, ""); + //id is now of the form "c" + + return id; + } + /* Move on to the next test */ this.getNextTest = function() { if(testGroups.length == 0) { @@ -287,7 +301,8 @@ function TestLoader() { } else if(currentTestIndex < testGroups[testGroupIndex].tests.length) { // We have tests left in this test group. var test = testGroups[testGroupIndex].tests[currentTestIndex++]; - var scriptCode = test.code; + var scriptCode = test.code; + scriptCode.id = getIdFromPath(test.path); //var scriptCode = (test.firstChild.text != undefined) ? // test.firstChild.text : test.firstChild.textContent; From 54b6ae5e9cc1495526b6b10d75c3003eeea9eeaf Mon Sep 17 00:00:00 2001 From: David Fugate Date: Sat, 24 Sep 2011 11:47:48 -0700 Subject: [PATCH 3/3] Moved resources and images directories (from website) up a couple levels. Added new 'packaging' directory to tooling. --- tools/packaging/TestCasePackagerConfig.py | 16 +++++----- tools/packaging/common.py | 13 ++++++++ tools/packaging/packager.py | 16 +--------- tools/packaging/templates/runner.test262.html | 30 ++++++++---------- website/{resources => }/images/back.png | Bin website/{resources => }/images/button_bg.png | Bin .../{resources => }/images/ecmascriptlogo.png | Bin website/{resources => }/images/fade.jpg | Bin website/{resources => }/images/logo.png | Bin website/{resources => }/images/pause.png | Bin .../{resources => }/images/progressbarbg.png | Bin website/{resources => }/images/rerun.png | Bin website/{resources => }/images/reset.png | Bin website/{resources => }/images/resume.png | Bin .../images/selectedbutton_bg.png | Bin website/{resources => }/images/spinner.gif | Bin website/{resources => }/images/splitter.png | Bin website/{resources => }/images/start.png | Bin website/{resources => }/images/stop.png | Bin .../{resources => }/images/tblheaderbg.png | Bin .../images/tblreportheaderbg.png | Bin .../images/tblsectionheader.png | Bin website/{resources => }/images/tc39.png | Bin website/{resources => }/styles/style.css | 0 24 files changed, 36 insertions(+), 39 deletions(-) create mode 100644 tools/packaging/common.py rename website/{resources => }/images/back.png (100%) rename website/{resources => }/images/button_bg.png (100%) rename website/{resources => }/images/ecmascriptlogo.png (100%) rename website/{resources => }/images/fade.jpg (100%) rename website/{resources => }/images/logo.png (100%) rename website/{resources => }/images/pause.png (100%) rename website/{resources => }/images/progressbarbg.png (100%) rename website/{resources => }/images/rerun.png (100%) rename website/{resources => }/images/reset.png (100%) rename website/{resources => }/images/resume.png (100%) rename website/{resources => }/images/selectedbutton_bg.png (100%) rename website/{resources => }/images/spinner.gif (100%) rename website/{resources => }/images/splitter.png (100%) rename website/{resources => }/images/start.png (100%) rename website/{resources => }/images/stop.png (100%) rename website/{resources => }/images/tblheaderbg.png (100%) rename website/{resources => }/images/tblreportheaderbg.png (100%) rename website/{resources => }/images/tblsectionheader.png (100%) rename website/{resources => }/images/tc39.png (100%) rename website/{resources => }/styles/style.css (100%) diff --git a/tools/packaging/TestCasePackagerConfig.py b/tools/packaging/TestCasePackagerConfig.py index 9364556d70..e92f27b933 100644 --- a/tools/packaging/TestCasePackagerConfig.py +++ b/tools/packaging/TestCasePackagerConfig.py @@ -26,12 +26,11 @@ import stat #--Globals--------------------------------------------------------------------- MAX_CASES_PER_JSON = 1000 +WEBSITE_SHORT_NAME = "website2" + #Directories under "test\suite\" containing ES5 test chapter directories #with *.js tests underneath them -TEST_CONTRIB_DIRS = ["sputnik_converted", "ietestcenter"] - -#Global scope source files found directly under "test\suite\". -GLOBAL_SCOPE_FILES = ["SputnikGlobalScope.js", "IETCGlobalScope.js"] +TEST_CONTRIB_DIRS = ["converted"] #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__)), "..", "..") @@ -45,18 +44,19 @@ TEST262_CASES_DIR = os.path.join(TEST262_ROOT, "test", "suite") 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", "resources", "scripts", "testcases") +TEST262_WEB_CASES_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, "json") #Directory containing the website's test harness (ported over from TEST262_HARNESS_DIR) -TEST262_WEB_HARNESS_DIR = os.path.join(TEST262_ROOT, "website", "resources", "scripts", "global") +TEST262_WEB_HARNESS_DIR = os.path.join(TEST262_ROOT, WEBSITE_SHORT_NAME, "harness") #Path to the ported test case files on the actual website as opposed to the Hg layout -WEBSITE_CASES_PATH = "resources/scripts/testcases/" +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") + #------------------------------------------------------------------------------ TEMPLATE_LINES = None @@ -70,7 +70,7 @@ def generateHarness(harnessType, jsonName, title): TEMPLATE_LINES = [] 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", 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) diff --git a/tools/packaging/common.py b/tools/packaging/common.py new file mode 100644 index 0000000000..ba4ffba5dd --- /dev/null +++ b/tools/packaging/common.py @@ -0,0 +1,13 @@ +#--Imports--------------------------------------------------------------------- + +#--Stubs----------------------------------------------------------------------- + + + +#--Globals--------------------------------------------------------------------- + + +#--Helpers--------------------------------------------------------------------# + + +#--MAIN------------------------------------------------------------------------ diff --git a/tools/packaging/packager.py b/tools/packaging/packager.py index 7c7a02d145..f1ee23e5f4 100644 --- a/tools/packaging/packager.py +++ b/tools/packaging/packager.py @@ -1,4 +1,4 @@ -# Copyright (c) 2009 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: @@ -291,18 +291,4 @@ if TEST262_HARNESS_DIR!=TEST262_WEB_HARNESS_DIR: if not fileExists: SC_HELPER.add(toFilename) -#Copying the global scope files over as well -#TODO: really the HTML harness file should be generated as well... -print "" -print "Deploying global scope metadata files to 'TEST262_WEB_HARNESS_DIR'..." -for gsf in GLOBAL_SCOPE_FILES: - toFilename = os.path.join(TEST262_WEB_CASES_DIR, gsf) - fileExists = os.path.exists(toFilename) - if fileExists: - SC_HELPER.edit(toFilename) - shutil.copy(os.path.join(TEST262_CASES_DIR, gsf), - toFilename) - if not fileExists: - SC_HELPER.add(toFilename) - print "Done." diff --git a/tools/packaging/templates/runner.test262.html b/tools/packaging/templates/runner.test262.html index 3bfea29f25..47331606f0 100644 --- a/tools/packaging/templates/runner.test262.html +++ b/tools/packaging/templates/runner.test262.html @@ -2,20 +2,18 @@ - - + + - - - - - - - - + + + + + + ECMAScript Test262 - +
@@ -40,7 +38,7 @@
- Loading... + Loading... Loading...
@@ -49,7 +47,7 @@
-
+
@@ -106,7 +104,7 @@
-   +  
@@ -149,7 +147,7 @@ Test Suite Ver.:  | Test Suite Date:
 100%  diff --git a/website/resources/images/back.png b/website/images/back.png similarity index 100% rename from website/resources/images/back.png rename to website/images/back.png diff --git a/website/resources/images/button_bg.png b/website/images/button_bg.png similarity index 100% rename from website/resources/images/button_bg.png rename to website/images/button_bg.png diff --git a/website/resources/images/ecmascriptlogo.png b/website/images/ecmascriptlogo.png similarity index 100% rename from website/resources/images/ecmascriptlogo.png rename to website/images/ecmascriptlogo.png diff --git a/website/resources/images/fade.jpg b/website/images/fade.jpg similarity index 100% rename from website/resources/images/fade.jpg rename to website/images/fade.jpg diff --git a/website/resources/images/logo.png b/website/images/logo.png similarity index 100% rename from website/resources/images/logo.png rename to website/images/logo.png diff --git a/website/resources/images/pause.png b/website/images/pause.png similarity index 100% rename from website/resources/images/pause.png rename to website/images/pause.png diff --git a/website/resources/images/progressbarbg.png b/website/images/progressbarbg.png similarity index 100% rename from website/resources/images/progressbarbg.png rename to website/images/progressbarbg.png diff --git a/website/resources/images/rerun.png b/website/images/rerun.png similarity index 100% rename from website/resources/images/rerun.png rename to website/images/rerun.png diff --git a/website/resources/images/reset.png b/website/images/reset.png similarity index 100% rename from website/resources/images/reset.png rename to website/images/reset.png diff --git a/website/resources/images/resume.png b/website/images/resume.png similarity index 100% rename from website/resources/images/resume.png rename to website/images/resume.png diff --git a/website/resources/images/selectedbutton_bg.png b/website/images/selectedbutton_bg.png similarity index 100% rename from website/resources/images/selectedbutton_bg.png rename to website/images/selectedbutton_bg.png diff --git a/website/resources/images/spinner.gif b/website/images/spinner.gif similarity index 100% rename from website/resources/images/spinner.gif rename to website/images/spinner.gif diff --git a/website/resources/images/splitter.png b/website/images/splitter.png similarity index 100% rename from website/resources/images/splitter.png rename to website/images/splitter.png diff --git a/website/resources/images/start.png b/website/images/start.png similarity index 100% rename from website/resources/images/start.png rename to website/images/start.png diff --git a/website/resources/images/stop.png b/website/images/stop.png similarity index 100% rename from website/resources/images/stop.png rename to website/images/stop.png diff --git a/website/resources/images/tblheaderbg.png b/website/images/tblheaderbg.png similarity index 100% rename from website/resources/images/tblheaderbg.png rename to website/images/tblheaderbg.png diff --git a/website/resources/images/tblreportheaderbg.png b/website/images/tblreportheaderbg.png similarity index 100% rename from website/resources/images/tblreportheaderbg.png rename to website/images/tblreportheaderbg.png diff --git a/website/resources/images/tblsectionheader.png b/website/images/tblsectionheader.png similarity index 100% rename from website/resources/images/tblsectionheader.png rename to website/images/tblsectionheader.png diff --git a/website/resources/images/tc39.png b/website/images/tc39.png similarity index 100% rename from website/resources/images/tc39.png rename to website/images/tc39.png diff --git a/website/resources/styles/style.css b/website/styles/style.css similarity index 100% rename from website/resources/styles/style.css rename to website/styles/style.css