Skip to content
Snippets Groups Projects
Commit 2bf9e7e2 authored by David Fugate's avatar David Fugate
Browse files

Merge.

parents 5c91ef1c 2b0122ef
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
//An exception is expected //An exception is expected
if (testDescrip.negative !== undefined) { if (testDescrip.negative !== undefined) {
testDescrip.negative = testDescrip.negative !== "" ? testDescrip.negative : ".";
if (window.iframeError === undefined) { //no exception was thrown if (window.iframeError === undefined) { //no exception was thrown
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code, testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
'fail', 'fail',
......
...@@ -33,7 +33,7 @@ function Presenter() { ...@@ -33,7 +33,7 @@ function Presenter() {
totalTests = 0; totalTests = 0;
var progressBar; var progressBar;
TOCFILEPATH = "resources/scripts/global/ecma-262-toc.xml"; TOCFILEPATH = "metadata/ecma-262-toc.xml";
//**INTERFACE**************************************************************** //**INTERFACE****************************************************************
/* Updates progress with the given test, which should have its results in it as well. */ /* Updates progress with the given test, which should have its results in it as well. */
this.addTestResult = function(test) { this.addTestResult = function(test) {
...@@ -69,7 +69,7 @@ function Presenter() { ...@@ -69,7 +69,7 @@ function Presenter() {
} }
this.finished = function(elapsed) { this.finished = function(elapsed) {
$('.button-start').attr('src', 'resources/images/start.png'); $('.button-start').attr('src', 'images/start.png');
$('.button-start').fadeOut('fast'); $('.button-start').fadeOut('fast');
progressBar.find(".text").html("Testing complete!"); progressBar.find(".text").html("Testing complete!");
...@@ -81,11 +81,11 @@ function Presenter() { ...@@ -81,11 +81,11 @@ function Presenter() {
} }
this.started = function () { this.started = function () {
$('.button-start').attr('src', 'resources/images/pause.png'); $('.button-start').attr('src', 'images/pause.png');
} }
this.paused = function () { this.paused = function () {
$('.button-start').attr('src', 'resources/images/resume.png'); $('.button-start').attr('src', 'images/resume.png');
} }
this.reset = function() { this.reset = function() {
......
...@@ -285,31 +285,8 @@ var EarlyErrorRePat = "^((?!" + NotEarlyErrorString + ").)*$"; ...@@ -285,31 +285,8 @@ var EarlyErrorRePat = "^((?!" + NotEarlyErrorString + ").)*$";
var NotEarlyError = new Error(NotEarlyErrorString); var NotEarlyError = new Error(NotEarlyErrorString);
//--Test case registration----------------------------------------------------- //--Test case registration-----------------------------------------------------
var ES5Harness = {}; function runTestCase(testcase) {
ES5Harness.registerTest = function (test) { if (testcase() !== true) {
var error; $ERROR("Test case returned non-true value!")
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");
}
}
} }
//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);
} }
...@@ -41,7 +41,7 @@ function BrowserRunner() { ...@@ -41,7 +41,7 @@ function BrowserRunner() {
errorDetectorFileContents, errorDetectorFileContents,
simpleTestAPIContents, simpleTestAPIContents,
globalScopeContents, globalScopeContents,
harnessDir = "resources/scripts/global/"; harnessDir = "harness/";
$.ajax({async: false, $.ajax({async: false,
dataType: "text", dataType: "text",
...@@ -99,18 +99,19 @@ function BrowserRunner() { ...@@ -99,18 +99,19 @@ function BrowserRunner() {
/* Run the test. */ /* Run the test. */
this.run = function (test, code) { this.run = function (test, code) {
currentTest = { id: test.id, currentTest = {};
path: test.path, for (var tempIndex in test) {
code: code, if (test.hasOwnProperty(tempIndex)) {
}; // default test, in case it doesn't get registered. currentTest[tempIndex] = test[tempIndex];
}
var isGlobalTest = GlobalScopeTests[test.path] !== undefined; }
currentTest.code = code;
iframe = document.createElement("iframe"); iframe = document.createElement("iframe");
iframe.setAttribute("id", "runnerIframe"); iframe.setAttribute("id", "runnerIframe");
//FireFox has a defect where it doesn't fire window.onerror for an iframe if the iframe //FireFox has a defect where it doesn't fire window.onerror for an iframe if the iframe
//is invisible. //is invisible.
if (!isGlobalTest || !/firefox/i.test(navigator.userAgent)) { if (!/firefox/i.test(navigator.userAgent)) {
iframe.setAttribute("style", "display:none"); iframe.setAttribute("style", "display:none");
} }
document.body.appendChild(iframe); document.body.appendChild(iframe);
...@@ -128,23 +129,23 @@ function BrowserRunner() { ...@@ -128,23 +129,23 @@ function BrowserRunner() {
include; include;
iwin.Test262Error = Test262Error; iwin.Test262Error = Test262Error;
iwin.$ERROR = $ERROR; iwin.$ERROR = $ERROR;
iwin.$FAIL = $FAIL; iwin.$FAIL = $FAIL;
iwin.$PRINT = function () {}; iwin.$PRINT = function () { };
iwin.$INCLUDE = function() {}; iwin.$INCLUDE = function () { };
if(includes !== null) { if (includes !== null) {
// We have some includes, so loop through each include and // We have some includes, so loop through each include and
// pull in the dependencies. // pull in the dependencies.
for(var i = 0; i < includes.length; i++) { for (var i = 0; i < includes.length; i++) {
include = includes[i].replace(/.*\(('|")(.*)('|")\)/, "$2"); include = includes[i].replace(/.*\(('|")(.*)('|")\)/, "$2");
// First check to see if we have this script cached // First check to see if we have this script cached
// already, and if not, grab it. // already, and if not, grab it.
if(typeof scriptCache[include] === "undefined") { if (typeof scriptCache[include] === "undefined") {
$.ajax({ $.ajax({
async: false, async: false,
url: 'resources/scripts/global/' + include, url: 'harness/' + include,
success: function(s) { scriptCache[include] = s; } success: function (s) { scriptCache[include] = s; }
}); });
} }
...@@ -159,42 +160,30 @@ function BrowserRunner() { ...@@ -159,42 +160,30 @@ function BrowserRunner() {
idoc.writeln(simpleTestAPIContents); idoc.writeln(simpleTestAPIContents);
idoc.writeln("</script>"); idoc.writeln("</script>");
//--Scenario 1: we're dealing with a global scope test case iwin.iframeError = undefined;
if (isGlobalTest) { iwin.onerror = undefined;
iwin.iframeError = undefined; iwin.testDescrip = currentTest;
iwin.onerror = undefined;
var testDescrip = GlobalScopeTests[test.path]; //Add an error handler capable of catching so-called early errors
testDescrip.id = test.id; //idoc.writeln("<script type='text/javascript' src='harness/ed.js'>" + "</script>");
testDescrip.path = test.path; idoc.writeln("<script type='text/javascript'>");
testDescrip.code = code; idoc.writeln(errorDetectorFileContents);
iwin.testDescrip = testDescrip; idoc.writeln("</script>");
//Add an error handler capable of catching so-called early errors //Run the code
//idoc.writeln("<script type='text/javascript' src='harness/ed.js'>" + "</script>"); idoc.writeln("<script type='text/javascript'>");
idoc.writeln("<script type='text/javascript'>"); if (/opera/i.test(navigator.userAgent)) { //Opera doesn't support window.onerror
idoc.writeln(errorDetectorFileContents); idoc.writeln("try {eval(\"" + this.convertForEval(code) + "\");} catch(e) {window.onerror(e.toString(), null, null);}");
idoc.writeln("</script>"); } else {
idoc.writeln(code);
//Run the code
idoc.writeln("<script type='text/javascript'>");
if (/opera/i.test(navigator.userAgent)) { //Opera doesn't support window.onerror
idoc.writeln("try {eval(\"" + this.convertForEval(code) + "\");} catch(e) {window.onerror(e.toString(), null, null);}");
} else {
idoc.writeln(code);
}
idoc.writeln("</script>");
//Validate the results
//idoc.writeln("<script type='text/javascript' src='harness/gs.js' defer>" + "</script>");
idoc.writeln("<script type='text/javascript'>");
idoc.writeln(globalScopeContents);
idoc.writeln("</script>");
}
//--Scenario 2: we're dealing with a normal positive(?) test case
else {
idoc.writeln("<script type='text/javascript'>" + code + "</script>");
idoc.writeln("<script type='text/javascript' defer>testFinished();" + "</script>");
} }
idoc.writeln("</script>");
//Validate the results
//idoc.writeln("<script type='text/javascript' src='harness/gs.js' defer>" + "</script>");
idoc.writeln("<script type='text/javascript'>");
idoc.writeln(globalScopeContents);
idoc.writeln("</script>");
idoc.close(); idoc.close();
} }
...@@ -278,7 +267,7 @@ function TestLoader() { ...@@ -278,7 +267,7 @@ function TestLoader() {
}}); }});
} }
this.getIdFromPath = function(path) { function getIdFromPath (path) {
//path is of the form "a/b/c.js" //path is of the form "a/b/c.js"
var id = path.split("/"); var id = path.split("/");
...@@ -302,7 +291,7 @@ function TestLoader() { ...@@ -302,7 +291,7 @@ function TestLoader() {
// We have tests left in this test group. // We have tests left in this test group.
var test = testGroups[testGroupIndex].tests[currentTestIndex++]; var test = testGroups[testGroupIndex].tests[currentTestIndex++];
var scriptCode = test.code; var scriptCode = test.code;
scriptCode.id = getIdFromPath(test.path); test.id = getIdFromPath(test.path);
//var scriptCode = (test.firstChild.text != undefined) ? //var scriptCode = (test.firstChild.text != undefined) ?
// test.firstChild.text : test.firstChild.textContent; // test.firstChild.text : test.firstChild.textContent;
......
...@@ -78,7 +78,7 @@ def generateHarness(harnessType, jsonName, title): ...@@ -78,7 +78,7 @@ def generateHarness(harnessType, jsonName, title):
with open(fileName, "w") as f: with open(fileName, "w") as f:
for line in TEMPLATE_LINES: for line in TEMPLATE_LINES:
if "var TEST_LIST_PATH =" in line: if "var TEST_LIST_PATH =" in line:
f.write(" var TEST_LIST_PATH = \"resources/scripts/testcases/" + jsonName + "\";" + os.linesep) f.write(" var TEST_LIST_PATH = \"json/" + jsonName + "\";" + os.linesep)
#elif "ECMAScript 5" in line: #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: else:
......
#--Imports--------------------------------------------------------------------- #--Imports---------------------------------------------------------------------
import re
#--Stubs----------------------------------------------------------------------- #--Stubs-----------------------------------------------------------------------
#--Globals--------------------------------------------------------------------- #--Globals---------------------------------------------------------------------
captureCommentPattern = re.compile(r"\/\*\*?((?:\s|\S)*?)\*\/\s*\n")
atattrs = re.compile(r"\s*\n\s*\*\s*@")
stars = re.compile(r"\s*\n\s*\*\s?")
#--Helpers--------------------------------------------------------------------# #--Helpers--------------------------------------------------------------------#
def stripStars(text):
return stars.sub('\n', text).strip()
def convertDocString(docString):
envelope = {}
temp = captureCommentPattern.findall(docString)[0]
propTexts = atattrs.split(temp)
envelope['commentary'] = stripStars(propTexts[0])
del propTexts[0]
for propText in propTexts:
# TODO: error check for mismatch
propName = re.match(r"^\w+", propText).group(0)
propVal = propText[len(propName):]
# Just till last one-time conversion
# strip optional initial colon or final semicolon.
# The initial colon is only stripped if it comes immediately
# after the identifier with no intervening whitespace.
propVal = re.sub(r"^:\s*", '', propVal, 1)
propVal = re.sub(r";\s*$", '', propVal, 1)
propVal = stripStars(propVal)
if propName in envelope:
raise Exception('duplicate: ' + propName)
envelope[propName] = propVal;
return envelope
#--MAIN------------------------------------------------------------------------ #--MAIN------------------------------------------------------------------------
...@@ -30,6 +30,8 @@ import re ...@@ -30,6 +30,8 @@ import re
import json import json
import stat import stat
from common import convertDocString
#--Stubs----------------------------------------------------------------------- #--Stubs-----------------------------------------------------------------------
def generateHarness(harnessType, jsonFile, description): def generateHarness(harnessType, jsonFile, description):
pass pass
...@@ -144,7 +146,8 @@ def isTestStarted(line): ...@@ -144,7 +146,8 @@ def isTestStarted(line):
or Sputnik tests. or Sputnik tests.
''' '''
global IS_MULTILINE_COMMENT global IS_MULTILINE_COMMENT
#TODO
return True
if IS_MULTILINE_COMMENT and ("*/" in line): #End of a newline comment if IS_MULTILINE_COMMENT and ("*/" in line): #End of a newline comment
IS_MULTILINE_COMMENT = False IS_MULTILINE_COMMENT = False
return False return False
...@@ -180,7 +183,6 @@ for temp in TEST_CONTRIB_DIRS: ...@@ -180,7 +183,6 @@ for temp in TEST_CONTRIB_DIRS:
else: else:
for tempSubdir in os.listdir(temp): for tempSubdir in os.listdir(temp):
TEST_SUITE_SECTIONS.append(os.path.join(temp, tempSubdir)) TEST_SUITE_SECTIONS.append(os.path.join(temp, tempSubdir))
for chapter in TEST_SUITE_SECTIONS: for chapter in TEST_SUITE_SECTIONS:
chapterName = chapter.rsplit(os.path.sep, 1)[1] chapterName = chapter.rsplit(os.path.sep, 1)[1]
...@@ -205,7 +207,8 @@ for chapter in TEST_SUITE_SECTIONS: ...@@ -205,7 +207,8 @@ for chapter in TEST_SUITE_SECTIONS:
if EXCLUDE_LIST.count(testName)==0: if EXCLUDE_LIST.count(testName)==0:
# dictionary for each test # dictionary for each test
testDict = {} testDict = {}
testDict["id"] = testName #TODO
#testDict["id"] = testName
testDict["path"] = testPath.replace("/ietestcenter", "").replace("/sputnik_converted", "") testDict["path"] = testPath.replace("/ietestcenter", "").replace("/sputnik_converted", "")
tempFile = open(test, "r") tempFile = open(test, "r")
...@@ -233,6 +236,13 @@ for chapter in TEST_SUITE_SECTIONS: ...@@ -233,6 +236,13 @@ for chapter in TEST_SUITE_SECTIONS:
testDict["code"] = scriptCodeContent testDict["code"] = scriptCodeContent
#now close the dictionary for the test #now close the dictionary for the test
#now get the metadata added.
tempDict = convertDocString("".join(scriptCode))
for tempKey in tempDict.keys():
#TODO - is this check really necessary?
if not (tempKey in ["path"]):
testDict[tempKey] = tempDict[tempKey]
#this adds the test to our tests array #this adds the test to our tests array
tests.append(testDict) tests.append(testDict)
testCount += 1 testCount += 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment