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 @@
//An exception is expected
if (testDescrip.negative !== undefined) {
testDescrip.negative = testDescrip.negative !== "" ? testDescrip.negative : ".";
if (window.iframeError === undefined) { //no exception was thrown
testRun(testDescrip.id, testDescrip.path, testDescrip.description, testDescrip.code,
'fail',
......
......@@ -33,7 +33,7 @@ function Presenter() {
totalTests = 0;
var progressBar;
TOCFILEPATH = "resources/scripts/global/ecma-262-toc.xml";
TOCFILEPATH = "metadata/ecma-262-toc.xml";
//**INTERFACE****************************************************************
/* Updates progress with the given test, which should have its results in it as well. */
this.addTestResult = function(test) {
......@@ -69,7 +69,7 @@ function Presenter() {
}
this.finished = function(elapsed) {
$('.button-start').attr('src', 'resources/images/start.png');
$('.button-start').attr('src', 'images/start.png');
$('.button-start').fadeOut('fast');
progressBar.find(".text").html("Testing complete!");
......@@ -81,11 +81,11 @@ function Presenter() {
}
this.started = function () {
$('.button-start').attr('src', 'resources/images/pause.png');
$('.button-start').attr('src', 'images/pause.png');
}
this.paused = function () {
$('.button-start').attr('src', 'resources/images/resume.png');
$('.button-start').attr('src', 'images/resume.png');
}
this.reset = function() {
......
......@@ -285,31 +285,8 @@ var EarlyErrorRePat = "^((?!" + NotEarlyErrorString + ").)*$";
var NotEarlyError = new Error(NotEarlyErrorString);
//--Test case registration-----------------------------------------------------
var ES5Harness = {};
ES5Harness.registerTest = function (test) {
var error;
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");
}
}
function runTestCase(testcase) {
if (testcase() !== true) {
$ERROR("Test case returned non-true value!")
}
//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() {
errorDetectorFileContents,
simpleTestAPIContents,
globalScopeContents,
harnessDir = "resources/scripts/global/";
harnessDir = "harness/";
$.ajax({async: false,
dataType: "text",
......@@ -99,18 +99,19 @@ function BrowserRunner() {
/* Run the test. */
this.run = function (test, code) {
currentTest = { id: test.id,
path: test.path,
code: code,
}; // default test, in case it doesn't get registered.
var isGlobalTest = GlobalScopeTests[test.path] !== undefined;
currentTest = {};
for (var tempIndex in test) {
if (test.hasOwnProperty(tempIndex)) {
currentTest[tempIndex] = test[tempIndex];
}
}
currentTest.code = code;
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
//is invisible.
if (!isGlobalTest || !/firefox/i.test(navigator.userAgent)) {
if (!/firefox/i.test(navigator.userAgent)) {
iframe.setAttribute("style", "display:none");
}
document.body.appendChild(iframe);
......@@ -128,23 +129,23 @@ function BrowserRunner() {
include;
iwin.Test262Error = Test262Error;
iwin.$ERROR = $ERROR;
iwin.$FAIL = $FAIL;
iwin.$PRINT = function () {};
iwin.$INCLUDE = function() {};
iwin.$FAIL = $FAIL;
iwin.$PRINT = function () { };
iwin.$INCLUDE = function () { };
if(includes !== null) {
if (includes !== null) {
// We have some includes, so loop through each include and
// 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");
// First check to see if we have this script cached
// already, and if not, grab it.
if(typeof scriptCache[include] === "undefined") {
if (typeof scriptCache[include] === "undefined") {
$.ajax({
async: false,
url: 'resources/scripts/global/' + include,
success: function(s) { scriptCache[include] = s; }
url: 'harness/' + include,
success: function (s) { scriptCache[include] = s; }
});
}
......@@ -159,42 +160,30 @@ function BrowserRunner() {
idoc.writeln(simpleTestAPIContents);
idoc.writeln("</script>");
//--Scenario 1: we're dealing with a global scope test case
if (isGlobalTest) {
iwin.iframeError = undefined;
iwin.onerror = undefined;
var testDescrip = GlobalScopeTests[test.path];
testDescrip.id = test.id;
testDescrip.path = test.path;
testDescrip.code = code;
iwin.testDescrip = testDescrip;
//Add an error handler capable of catching so-called early errors
//idoc.writeln("<script type='text/javascript' src='harness/ed.js'>" + "</script>");
idoc.writeln("<script type='text/javascript'>");
idoc.writeln(errorDetectorFileContents);
idoc.writeln("</script>");
//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>");
iwin.iframeError = undefined;
iwin.onerror = undefined;
iwin.testDescrip = currentTest;
//Add an error handler capable of catching so-called early errors
//idoc.writeln("<script type='text/javascript' src='harness/ed.js'>" + "</script>");
idoc.writeln("<script type='text/javascript'>");
idoc.writeln(errorDetectorFileContents);
idoc.writeln("</script>");
//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>");
idoc.close();
}
......@@ -278,7 +267,7 @@ function TestLoader() {
}});
}
this.getIdFromPath = function(path) {
function getIdFromPath (path) {
//path is of the form "a/b/c.js"
var id = path.split("/");
......@@ -302,7 +291,7 @@ function TestLoader() {
// We have tests left in this test group.
var test = testGroups[testGroupIndex].tests[currentTestIndex++];
var scriptCode = test.code;
scriptCode.id = getIdFromPath(test.path);
test.id = getIdFromPath(test.path);
//var scriptCode = (test.firstChild.text != undefined) ?
// test.firstChild.text : test.firstChild.textContent;
......
......@@ -78,7 +78,7 @@ 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 = \"resources/scripts/testcases/" + 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))
else:
......
#--Imports---------------------------------------------------------------------
import re
#--Stubs-----------------------------------------------------------------------
#--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--------------------------------------------------------------------#
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------------------------------------------------------------------------
......@@ -30,6 +30,8 @@ import re
import json
import stat
from common import convertDocString
#--Stubs-----------------------------------------------------------------------
def generateHarness(harnessType, jsonFile, description):
pass
......@@ -144,7 +146,8 @@ def isTestStarted(line):
or Sputnik tests.
'''
global IS_MULTILINE_COMMENT
#TODO
return True
if IS_MULTILINE_COMMENT and ("*/" in line): #End of a newline comment
IS_MULTILINE_COMMENT = False
return False
......@@ -180,7 +183,6 @@ for temp in TEST_CONTRIB_DIRS:
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]
......@@ -205,7 +207,8 @@ for chapter in TEST_SUITE_SECTIONS:
if EXCLUDE_LIST.count(testName)==0:
# dictionary for each test
testDict = {}
testDict["id"] = testName
#TODO
#testDict["id"] = testName
testDict["path"] = testPath.replace("/ietestcenter", "").replace("/sputnik_converted", "")
tempFile = open(test, "r")
......@@ -233,6 +236,13 @@ for chapter in TEST_SUITE_SECTIONS:
testDict["code"] = scriptCodeContent
#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
tests.append(testDict)
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