diff options
author | David Fugate <dfugate@microsoft.com> | 2011-09-24 16:35:45 -0700 |
---|---|---|
committer | David Fugate <dfugate@microsoft.com> | 2011-09-24 16:35:45 -0700 |
commit | 2b0122ef821b1b1445ef39882c9026d67b2f72d2 (patch) | |
tree | dfe0aa4b2d097d626479113edbd040ca1a5c2f92 | |
parent | ab1142e49819d61dacf3d77f0f8411e6f7effa03 (diff) |
All tests are globally scoped tests - Part I.
-rw-r--r-- | test/harness/gs.js | 1 | ||||
-rw-r--r-- | test/harness/helper.js | 8 | ||||
-rw-r--r-- | test/harness/sta.js | 29 | ||||
-rw-r--r-- | test/harness/sth.js | 99 | ||||
-rw-r--r-- | tools/packaging/TestCasePackagerConfig.py | 2 | ||||
-rw-r--r-- | tools/packaging/common.py | 33 | ||||
-rw-r--r-- | tools/packaging/packager.py | 16 |
7 files changed, 97 insertions, 91 deletions
diff --git a/test/harness/gs.js b/test/harness/gs.js index 6916a1fd9..0fad6625d 100644 --- a/test/harness/gs.js +++ b/test/harness/gs.js @@ -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',
diff --git a/test/harness/helper.js b/test/harness/helper.js index 709c4f155..ba150c432 100644 --- a/test/harness/helper.js +++ b/test/harness/helper.js @@ -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() {
diff --git a/test/harness/sta.js b/test/harness/sta.js index 97c971f01..5e828c680 100644 --- a/test/harness/sta.js +++ b/test/harness/sta.js @@ -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);
}
diff --git a/test/harness/sth.js b/test/harness/sth.js index 50d6adabf..f60ce5758 100644 --- a/test/harness/sth.js +++ b/test/harness/sth.js @@ -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;
diff --git a/tools/packaging/TestCasePackagerConfig.py b/tools/packaging/TestCasePackagerConfig.py index e92f27b93..64210f794 100644 --- a/tools/packaging/TestCasePackagerConfig.py +++ b/tools/packaging/TestCasePackagerConfig.py @@ -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: diff --git a/tools/packaging/common.py b/tools/packaging/common.py index ba4ffba5d..568744e9f 100644 --- a/tools/packaging/common.py +++ b/tools/packaging/common.py @@ -1,13 +1,42 @@ #--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------------------------------------------------------------------------ diff --git a/tools/packaging/packager.py b/tools/packaging/packager.py index f1ee23e5f..c61d66820 100644 --- a/tools/packaging/packager.py +++ b/tools/packaging/packager.py @@ -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 |