aboutsummaryrefslogtreecommitdiffstats
path: root/test/harness/helper.js
diff options
context:
space:
mode:
authorDavid Fugate <dfugate@microsoft.com>2011-08-25 11:18:44 -0700
committerDavid Fugate <dfugate@microsoft.com>2011-08-25 11:18:44 -0700
commit28718864206f3254ed6fae9f1f630f2aa5005f79 (patch)
tree35ea93c8bbe32551cf799a0505953676c594cda7 /test/harness/helper.js
parentc21525a32814e57a60dafb3d410847ba5a9cb09c (diff)
test\harness\*:
- a lot of JS harness code written in strings have been moved out to actual physical files such as ed.js (syntax error detection for globally scoped tests) and gs.js (global scope test case validator). This change makes it far easier to maintain the test harness code - reorganized helper.js providing a clear indication which methods are used by external objects, which are implementation details, and which are unequivocally test262-specific. I've also added, openErrorWindow, which will be used to open a descriptive error message window for each test case failure reported on the 'Run' tab - improved the error message for syntax errors occurring when a test case fails to load - sta.js no longer tries to pickle all helper functions it contains! Instead, we load the file directly from sth.js. The performance of fnGlobalObject has been improved. Finally, the ES5Harness object has been moved from sth.js (in a string) to here - sth.js now has a browser implementer hook, controller.implementerHook, which allows browser implementers to handle test case failures in their own way (e.g., log to the filesystem). The 'run' function was basically re-written Added 37 new test cases from the "IE Test Center" Build release. There were 14 modifications to existing test cases as well. Refactored SputnikGlobalScope.js such that test case paths are now used as indices into the GlobalScopeTests array. TestCasePackager.py had the concept of templated test harnesses introduced - see templates\runner.test262.html. Also added support for one HTML test harness per ES5 chapter. Last but not least, TestCasePackagerConfig.py now has a 'source control' abstraction class which abstracts away source control adds|edits when dynamically generating *.json and *.html test chapters.
Diffstat (limited to 'test/harness/helper.js')
-rw-r--r--test/harness/helper.js355
1 files changed, 188 insertions, 167 deletions
diff --git a/test/harness/helper.js b/test/harness/helper.js
index a37be4d3f..8d89b67da 100644
--- a/test/harness/helper.js
+++ b/test/harness/helper.js
@@ -22,7 +22,6 @@
function Presenter() {
var altStyle = '',
logger,
- progressBar,
date,
version,
table,
@@ -33,39 +32,93 @@ function Presenter() {
tests = {},
totalTests = 0;
- TOCFILEPATH = "resources/scripts/global/ecma-262-toc.xml";
+ var progressBar;
+ TOCFILEPATH = "resources/scripts/global/ecma-262-toc.xml";
+ //**INTERFACE****************************************************************
+ /* Updates progress with the given test, which should have its results in it as well. */
+ this.addTestResult = function(test) {
+ tests[test.id] = test;
+ getSectionById(test.id).addTest(test);
-
- /* Load the table of contents xml to populate the sections. */
- function loadSections() {
- var sectionsLoader = new XMLHttpRequest();
- sectionsLoader.open("GET", TOCFILEPATH, false);
- sectionsLoader.send();
- var xmlDoc = sectionsLoader.responseXML;
- var nodes = xmlDoc.documentElement.childNodes;
+ updateCounts();
- addSectionsFromXML(nodes, globalSection);
+ if(test.result === 'fail') {
+ logResult(test);
+ }
+ }
+
+ this.setVersion = function(v) {
+ version = v;
+ $(".targetTestSuiteVersion").text(v);
+ }
+
+ this.setDate = function(d) {
+ date = d;
+ $(".targetTestSuiteDate").text(d);
+ }
+
+ this.setTotalTests = function(tests) {
+ totalTests = tests;
+ $('#testsToRun').text(tests);
+ }
+
+ /* Write status to the activity bar. */
+ this.updateStatus = function (str) {
+ this.activityBar.text(str);
+ }
+
+ this.finished = function(elapsed) {
+ $('.button-start').attr('src', 'resources/images/start.png');
+ if (isSiteDebugMode()) {
+ this.activityBar.text('Overall Execution Time: ' + elapsed + ' minutes');
+ } else {
+ activityBar.text('');
+ }
+ }
+
+ this.started = function () {
+ $('.button-start').attr('src', 'resources/images/pause.png');
}
+ this.paused = function () {
+ $('.button-start').attr('src', 'resources/images/resume.png');
+ }
- /* Recursively parses the TOC xml, producing nested sections. */
- function addSectionsFromXML(nodes, parentSection){
- var subsection;
+ this.reset = function() {
+ globalSection.reset();
+ updateCounts();
+ logger.empty();
- for (var i = 0; i < nodes.length; i++) {
- if (nodes[i].nodeName === "sec") {
- subsection = new Section(parentSection, nodes[i].getAttribute('id'), nodes[i].getAttribute('name'));
- parentSection.subsections[subsection.id.match(/\d+$/)] = subsection;
- addSectionsFromXML(nodes[i].childNodes, subsection);
- }
- }
+ currentSection = globalSection;
+ renderCurrentSection();
}
-
+
+
+ /* Do some setup tasks. */
+ this.setup = function() {
+ backLink = $('#backlinkDiv');
+ backLink.click(goBack);
+ table = $('.results-data-table');
+
+ logger = $("#tableLogger");
+ progressBar = $('#progressbar');
+ this.activityBar = $('#nextActivity');
+
+ $('a.showSource', logger).live("click", openSourceWindow);
+ $('a.showError', logger).live("click", openErrorWindow);
+ $('#ancGenXMLReport').click(createXMLReportWindow);
+ }
+
+ /* Refresh display of the report */
+ this.refresh = function() {
+ renderCurrentSection();
+ }
+
+ //**IMPLEMENTATION DETAILS***************************************************
/* Renders the current section into the report window. */
function renderCurrentSection() {
renderBreadcrumbs();
-
if(globalSection.totalTests === 0) {
$('#resultMessage').show();
} else {
@@ -76,53 +129,13 @@ function Presenter() {
$('.passedCases').text(currentSection.totalPassed);
$('.failedCases').text(currentSection.totalFailed);
$('#failedToLoadCounterDetails').text(currentSection.totalFailedToLoad);
-
table.empty();
table.append(currentSection.toHTML());
-
// Observe section selection and show source links
$('a.section', table).click(sectionSelected);
$('a.showSource', table).click(openSourceWindow);
}
- /* Renders the breadcrumbs for report navigation. */
- function renderBreadcrumbs() {
- var container = $('div.crumbContainer div.crumbs');
- var sectionChain = [];
-
- var current = currentSection;
-
- // Walk backwards until we reach the global section.
- while(current !== globalSection && current.parentSection !== globalSection) {
- sectionChain.push(current);
- current = current.parentSection;
- }
-
- // Reverse the array since we want to print earlier sections first.
- sectionChain.reverse();
-
- // Empty any existing breadcrumbs.
- container.empty();
-
- // Static first link to go back to the root.
- var link = $("<a href='#0' class='setBlack'>Test Sections &gt; </a>");
- link.bind('click', {sectionId: 0}, sectionSelected)
- container.append(link);
-
- for(var i = 0; i < sectionChain.length;i++) {
- link = $("<a href='#" + sectionChain[i].id + "' class='setBlack'>" + sectionChain[i].id + ": " + sectionChain[i].name + " &gt; </a>");
- link.bind('click', sectionSelected)
- container.append(link);
- }
-
- // If we can go back, show the back link.
- if(sectionChain.length > 0) {
- backLink.show();
- } else {
- backLink.hide();
- }
- }
-
/* Opens a window with a test's source code. */
function openSourceWindow(e) {
var test = tests[e.target.href.match(/#(.+)$/)[1]],
@@ -150,56 +163,23 @@ function Presenter() {
popWnd.document.write(innerHTML);
}
-
- /* Pops up a window with an xml dump of the results of a test. */
- function createXMLReportWindow() {
- var reportWindow; //window that will output the xml data
- var xmlData; //array instead of string concatenation
- var dateNow;
- var xml; // stop condition of for loop stored in a local variable to improve performance
-
- dateNow = new Date();
-
- xml = '<testRun>\r\n' +
- '<userAgent>' + window.navigator.userAgent + '</userAgent>\r\n' +
- '<Date>' + dateNow.toDateString() + '</Date>\r\n' +
- '<targetTestSuiteName>ECMAScript Test262 Site</targetTestSuiteName>\r\n' +
- '<targetTestSuiteVersion>' + version + '</targetTestSuiteVersion>\r\n' +
- '<targetTestSuiteDate>' + date + '</targetTestSuiteDate>\r\n' +
- ' <Tests>\r\n\r\n';
- reportWindow = window.open();
- reportWindow.document.writeln("<title>ECMAScript Test262 XML</title>");
- reportWindow.document.write("<textarea id='results' style='width: 100%; height: 800px;'>");
- reportWindow.document.write(xml);
- reportWindow.document.write(globalSection.toXML());
- reportWindow.document.write('</Tests>\r\n</testRun>\r\n</textarea>\r\n');
- reportWindow.document.close();
- }
-
- /* Callback for when the user clicks on a section in the report table. */
- function sectionSelected(e) {
- e.preventDefault();
- currentSection = getSectionById(e.target.href.match(/#(.+)$/)[1]);
- renderCurrentSection();
- table.attr("scrollTop", 0);
- }
-
- /* Go back to the previous section */
- function goBack(e) {
- e.preventDefault();
-
- if(currentSection === globalSection)
- return;
-
- currentSection = currentSection.parentSection;
+ /* Opens a window with a test's failure message. */
+ function openErrorWindow(e) {
+ var test = tests[e.target.href.match(/#(.+)$/)[1]],
+ popWnd = window.open("", "", "scrollbars=1, resizable=1"),
+ innerHTML = '';
- // Since users click directly on sub-chapters of the main chapters, don't go back to main
- // chapters.
- if(currentSection.parentSection === globalSection)
- currentSection = globalSection;
+ innerHTML += '<b>Test </b>';
+ innerHTML += '<b>' + test.id + '</b> <br /><br />';
- renderCurrentSection();
+ innerHTML += '<b>Failure</b>';
+ innerHTML += '<pre>' + test.error + '</pre>';
+
+ innerHTML += '<br /><br /><b>Testcase</b>';
+ innerHTML += '<pre>' + test.code + '</pre>';
+
+ popWnd.document.write(innerHTML);
}
/* Returns the section object for the specified section id (eg. "7.1" or "15.4.4.12"). */
@@ -217,7 +197,6 @@ function Presenter() {
break;
}
}
-
return section;
}
@@ -228,7 +207,6 @@ function Presenter() {
$('#totalCounter').text(globalSection.totalTests);
$('#failedToLoadCounter1').text(globalSection.totalFailedToLoad);
$('#failedToLoadCounter').text(globalSection.totalFailedToLoad);
-
progressBar.reportprogress(globalSection.totalTests, totalTests);
}
@@ -239,84 +217,127 @@ function Presenter() {
logger.append(appendStr);
logger.parent().attr("scrollTop", logger.parent().attr("scrollHeight"));
}
+
+
+
+ //*************************************************************************
+ /* Go back to the previous section */
+ function goBack(e) {
+ e.preventDefault();
- // Load the sections.
- loadSections();
+ if(currentSection === globalSection)
+ return;
- this.setTotalTests = function(tests) {
- totalTests = tests;
- $('#testsToRun').text(tests);
- }
+ currentSection = currentSection.parentSection;
- this.setVersion = function(v) {
- version = v;
- $(".targetTestSuiteVersion").text(v);
- }
+ // Since users click directly on sub-chapters of the main chapters, don't go back to main
+ // chapters.
+ if(currentSection.parentSection === globalSection)
+ currentSection = globalSection;
- this.setDate = function(d) {
- date = d;
- $(".targetTestSuiteDate").text(d);
+ renderCurrentSection();
}
+
+ /* Load the table of contents xml to populate the sections. */
+ function loadSections() {
+ var sectionsLoader = new XMLHttpRequest();
+ sectionsLoader.open("GET", TOCFILEPATH, false);
+ sectionsLoader.send();
+ var xmlDoc = sectionsLoader.responseXML;
+ var nodes = xmlDoc.documentElement.childNodes;
- /* Updates progress with the given test, which should have its results in it as well. */
- this.addTestResult = function(test) {
- tests[test.id] = test;
- getSectionById(test.id).addTest(test);
+ addSectionsFromXML(nodes, globalSection);
+ }
- updateCounts();
- if(test.result === 'fail')
- logResult(test);
+ /* Recursively parses the TOC xml, producing nested sections. */
+ function addSectionsFromXML(nodes, parentSection){
+ var subsection;
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].nodeName === "sec") {
+ subsection = new Section(parentSection, nodes[i].getAttribute('id'), nodes[i].getAttribute('name'));
+ parentSection.subsections[subsection.id.match(/\d+$/)] = subsection;
+ addSectionsFromXML(nodes[i].childNodes, subsection);
+ }
+ }
}
+
+ /* Renders the breadcrumbs for report navigation. */
+ function renderBreadcrumbs() {
+ var container = $('div.crumbContainer div.crumbs');
+ var sectionChain = [];
- this.started = function () {
- $('.button-start').attr('src', 'resources/images/pause.png');
- }
+ var current = currentSection;
- this.paused = function () {
- $('.button-start').attr('src', 'resources/images/resume.png');
- }
+ // Walk backwards until we reach the global section.
+ while(current !== globalSection && current.parentSection !== globalSection) {
+ sectionChain.push(current);
+ current = current.parentSection;
+ }
- this.reset = function() {
- globalSection.reset();
- updateCounts();
- logger.empty();
+ // Reverse the array since we want to print earlier sections first.
+ sectionChain.reverse();
- currentSection = globalSection;
- renderCurrentSection();
- }
+ // Empty any existing breadcrumbs.
+ container.empty();
- this.finished = function(elapsed) {
- $('.button-start').attr('src', 'resources/images/start.png');
- if (isSiteDebugMode()) {
- activityBar.text('Overall Execution Time: ' + elapsed + ' minutes');
+ // Static first link to go back to the root.
+ var link = $("<a href='#0' class='setBlack'>Test Sections &gt; </a>");
+ link.bind('click', {sectionId: 0}, sectionSelected)
+ container.append(link);
+
+ for(var i = 0; i < sectionChain.length;i++) {
+ link = $("<a href='#" + sectionChain[i].id + "' class='setBlack'>" + sectionChain[i].id + ": " + sectionChain[i].name + " &gt; </a>");
+ link.bind('click', sectionSelected)
+ container.append(link);
+ }
+
+ // If we can go back, show the back link.
+ if(sectionChain.length > 0) {
+ backLink.show();
} else {
- activityBar.text('');
+ backLink.hide();
}
}
+
+ /* Pops up a window with an xml dump of the results of a test. */
+ function createXMLReportWindow() {
+ var reportWindow; //window that will output the xml data
+ var xmlData; //array instead of string concatenation
+ var dateNow;
+ var xml; // stop condition of for loop stored in a local variable to improve performance
- /* Refresh display of the report */
- this.refresh = function() {
- renderCurrentSection();
- }
+ dateNow = new Date();
+
+ xml = '<testRun>\r\n' +
+ '<userAgent>' + window.navigator.userAgent + '</userAgent>\r\n' +
+ '<Date>' + dateNow.toDateString() + '</Date>\r\n' +
+ '<targetTestSuiteName>ECMAScript Test262 Site</targetTestSuiteName>\r\n' +
+ '<targetTestSuiteVersion>' + version + '</targetTestSuiteVersion>\r\n' +
+ '<targetTestSuiteDate>' + date + '</targetTestSuiteDate>\r\n' +
+ ' <Tests>\r\n\r\n';
- /* Write status to the activity bar. */
- this.updateStatus = function(str) {
- activityBar.text(str);
+ reportWindow = window.open();
+ reportWindow.document.writeln("<title>ECMAScript Test262 XML</title>");
+ reportWindow.document.write("<textarea id='results' style='width: 100%; height: 800px;'>");
+ reportWindow.document.write(xml);
+ reportWindow.document.write(globalSection.toXML());
+ reportWindow.document.write('</Tests>\r\n</testRun>\r\n</textarea>\r\n');
+ reportWindow.document.close();
}
- /* Do some setup tasks. */
- this.setup = function() {
- backLink = $('#backlinkDiv');
- backLink.click(goBack);
- table = $('.results-data-table');
- logger = $("#tableLogger");
- progressBar = $('#progressbar');
- activityBar = $('#nextActivity');
- $('a.showSource', logger).live("click", openSourceWindow);
- $('#ancGenXMLReport').click(createXMLReportWindow);
+ /* Callback for when the user clicks on a section in the report table. */
+ function sectionSelected(e) {
+ e.preventDefault();
+ currentSection = getSectionById(e.target.href.match(/#(.+)$/)[1]);
+ renderCurrentSection();
+ table.attr("scrollTop", 0);
}
+
+ //*************************************************************************
+ // Load the sections.
+ loadSections();
}
var presenter = new Presenter();