test\harness\helper.js: extended the 'finished' method to accept as input the total elapsed execution time

of the tests.  Emit this to the activity bar


test\harness\sta.js:  too many years of Python had me thinking JavaScript arrays have an append method:)  Fixed.
                      Also, added a pickled representation of all test helper functions found in this file


test\harness\sth.js:  detached most test helper functions from the iframe's document object (as globals) and
                      inject these into the actual test cases. It's a bit slower and not as elegant, but it is
                      cleaner from an ES5 purist perspective.  Still need to move Sputnik helper functions into
                      sta.js

                      Extended Controller such that it now measures overall test execution time.  Such a change
                      is very useful for measuring performance-impact changes such as the aforementioned
                      improvement
This commit is contained in:
David Fugate 2011-02-03 16:28:52 -08:00
parent 2ec3b287d7
commit e4d4a7a870
6 changed files with 58 additions and 44 deletions

View File

@ -289,9 +289,9 @@ function Presenter() {
renderCurrentSection();
}
this.finished = function() {
this.finished = function(elapsed) {
$('.button-start').attr('src', 'resources/images/start.png');
activityBar.text('');
activityBar.text('Overall Execution Time: ' + elapsed + ' minutes');
}
/* Refresh display of the report */

View File

@ -38,7 +38,7 @@ function compareArray(aExpected, aActual) {
}
return true;
}
SimpleTestAPIs.append(compareArray);
SimpleTestAPIs.push(compareArray);
//-----------------------------------------------------------------------------
function arrayContains(arr, expected) {
@ -57,7 +57,7 @@ function arrayContains(arr, expected) {
}
return true;
}
SimpleTestAPIs.append(arrayContains);
SimpleTestAPIs.push(arrayContains);
//-----------------------------------------------------------------------------
var supportsArrayIndexGettersOnArrays = undefined;
@ -81,7 +81,7 @@ function fnSupportsArrayIndexGettersOnArrays() {
return supportsArrayIndexGettersOnArrays;
}
SimpleTestAPIs.append(fnSupportsArrayIndexGettersOnArrays);
SimpleTestAPIs.push(fnSupportsArrayIndexGettersOnArrays);
//-----------------------------------------------------------------------------
var supportsArrayIndexGettersOnObjects = undefined;
@ -104,13 +104,13 @@ function fnSupportsArrayIndexGettersOnObjects() {
return supportsArrayIndexGettersOnObjects;
}
SimpleTestAPIs.append(fnSupportsArrayIndexGettersOnObjects);
SimpleTestAPIs.push(fnSupportsArrayIndexGettersOnObjects);
//-----------------------------------------------------------------------------
function ConvertToFileUrl(pathStr) {
return "file:" + pathStr.replace(/\\/g, "/");
}
SimpleTestAPIs.append(ConvertToFileUrl);
SimpleTestAPIs.push(ConvertToFileUrl);
//-----------------------------------------------------------------------------
function fnExists(/*arguments*/) {
@ -119,7 +119,7 @@ function fnExists(/*arguments*/) {
}
return true;
}
SimpleTestAPIs.append(fnExists);
SimpleTestAPIs.push(fnExists);
//-----------------------------------------------------------------------------
var supportsStrict = undefined;
@ -137,13 +137,13 @@ function fnSupportsStrict() {
}
return supportsStrict;
}
SimpleTestAPIs.append(fnSupportsStrict);
SimpleTestAPIs.push(fnSupportsStrict);
//-----------------------------------------------------------------------------
function fnGlobalObject() {
return (function() { return this }).call(null);
}
SimpleTestAPIs.append(fnGlobalObject);
SimpleTestAPIs.push(fnGlobalObject);
//-----------------------------------------------------------------------------
//Verify all attributes specified data property of given object: value, writable, enumerable, configurable
@ -207,7 +207,7 @@ function dataPropertyAttributesAreCorrect(obj, name, value, writable, enumerable
return attributesCorrect;
}
SimpleTestAPIs.append(dataPropertyAttributesAreCorrect);
SimpleTestAPIs.push(dataPropertyAttributesAreCorrect);
//-----------------------------------------------------------------------------
//Verify all attributes specified accessor property of given object: get, set, enumerable, configurable
@ -273,4 +273,6 @@ function accessorPropertyAttributesAreCorrect(obj, name, get, set, setVerifyHelp
return attributesCorrect;
}
SimpleTestAPIs.append(accessorPropertyAttributesAreCorrect);
SimpleTestAPIs.push(accessorPropertyAttributesAreCorrect);
//-----------------------------------------------------------------------------
var PickledSimpleTestAPIs = SimpleTestAPIs.join(" ");

View File

@ -91,20 +91,12 @@ function BrowserRunner() {
// Set up some globals.
win.testRun = testRun;
win.testFinished = testFinished;
win.fnSupportsStrict = fnSupportsStrict;
win.fnExists = fnExists;
win.ConvertToFileUrl = ConvertToFileUrl;
win.fnSupportsArrayIndexGettersOnObjects = fnSupportsArrayIndexGettersOnObjects;
win.fnSupportsArrayIndexGettersOnArrays = fnSupportsArrayIndexGettersOnArrays;
win.arrayContains = arrayContains;
win.compareArray = compareArray;
//TODO: these should be moved to sta.js
win.SputnikError = SputnikError;
win.$ERROR = $ERROR;
win.$FAIL = $FAIL;
win.$PRINT = function () {};
win.$INCLUDE = function() {};
win.dataPropertyAttributesAreCorrect = dataPropertyAttributesAreCorrect;
win.accessorPropertyAttributesAreCorrect = accessorPropertyAttributesAreCorrect;
if(includes !== null) {
// We have some includes, so loop through each include and pull in the dependencies.
@ -125,6 +117,10 @@ function BrowserRunner() {
}
}
//Write out all of our helper functions
doc.writeln("<script type='text/javascript'>" + PickledSimpleTestAPIs + "</script>");
// Write ES5Harness.registerTest and fnGlobalObject, which returns the global object, and the testFinished call.
doc.writeln("<script type='text/javascript'>ES5Harness = {};" +
"function fnGlobalObject() { return window; }" +
@ -243,6 +239,8 @@ function Controller() {
var runner = new BrowserRunner();
var loader = new TestLoader();
var controller = this;
var startTime;
var elapsed = 0;
runner.onComplete = function(test) {
presenter.addTestResult(test);
@ -268,21 +266,28 @@ function Controller() {
loader.onTestsExhausted = function() {
state = 'stopped';
presenter.finished();
elapsed += new Date() - startTime;
elapsed = elapsed/(1000*60); //minutes
elapsed = elapsed.toFixed(1);
presenter.finished(elapsed);
}
this.start = function() {
state = 'running';
startTime = new Date();
loader.getNextTest();
presenter.started();
}
this.pause = function() {
elapsed += new Date() - startTime;
state = 'paused';
presenter.paused();
}
this.reset = function() {
startTime = new Date();
elapsed = 0;
loader.reset();
presenter.reset();
}

View File

@ -289,9 +289,9 @@ function Presenter() {
renderCurrentSection();
}
this.finished = function() {
this.finished = function(elapsed) {
$('.button-start').attr('src', 'resources/images/start.png');
activityBar.text('');
activityBar.text('Overall Execution Time: ' + elapsed + ' minutes');
}
/* Refresh display of the report */

View File

@ -38,7 +38,7 @@ function compareArray(aExpected, aActual) {
}
return true;
}
SimpleTestAPIs.append(compareArray);
SimpleTestAPIs.push(compareArray);
//-----------------------------------------------------------------------------
function arrayContains(arr, expected) {
@ -57,7 +57,7 @@ function arrayContains(arr, expected) {
}
return true;
}
SimpleTestAPIs.append(arrayContains);
SimpleTestAPIs.push(arrayContains);
//-----------------------------------------------------------------------------
var supportsArrayIndexGettersOnArrays = undefined;
@ -81,7 +81,7 @@ function fnSupportsArrayIndexGettersOnArrays() {
return supportsArrayIndexGettersOnArrays;
}
SimpleTestAPIs.append(fnSupportsArrayIndexGettersOnArrays);
SimpleTestAPIs.push(fnSupportsArrayIndexGettersOnArrays);
//-----------------------------------------------------------------------------
var supportsArrayIndexGettersOnObjects = undefined;
@ -104,13 +104,13 @@ function fnSupportsArrayIndexGettersOnObjects() {
return supportsArrayIndexGettersOnObjects;
}
SimpleTestAPIs.append(fnSupportsArrayIndexGettersOnObjects);
SimpleTestAPIs.push(fnSupportsArrayIndexGettersOnObjects);
//-----------------------------------------------------------------------------
function ConvertToFileUrl(pathStr) {
return "file:" + pathStr.replace(/\\/g, "/");
}
SimpleTestAPIs.append(ConvertToFileUrl);
SimpleTestAPIs.push(ConvertToFileUrl);
//-----------------------------------------------------------------------------
function fnExists(/*arguments*/) {
@ -119,7 +119,7 @@ function fnExists(/*arguments*/) {
}
return true;
}
SimpleTestAPIs.append(fnExists);
SimpleTestAPIs.push(fnExists);
//-----------------------------------------------------------------------------
var supportsStrict = undefined;
@ -137,13 +137,13 @@ function fnSupportsStrict() {
}
return supportsStrict;
}
SimpleTestAPIs.append(fnSupportsStrict);
SimpleTestAPIs.push(fnSupportsStrict);
//-----------------------------------------------------------------------------
function fnGlobalObject() {
return (function() { return this }).call(null);
}
SimpleTestAPIs.append(fnGlobalObject);
SimpleTestAPIs.push(fnGlobalObject);
//-----------------------------------------------------------------------------
//Verify all attributes specified data property of given object: value, writable, enumerable, configurable
@ -207,7 +207,7 @@ function dataPropertyAttributesAreCorrect(obj, name, value, writable, enumerable
return attributesCorrect;
}
SimpleTestAPIs.append(dataPropertyAttributesAreCorrect);
SimpleTestAPIs.push(dataPropertyAttributesAreCorrect);
//-----------------------------------------------------------------------------
//Verify all attributes specified accessor property of given object: get, set, enumerable, configurable
@ -273,4 +273,6 @@ function accessorPropertyAttributesAreCorrect(obj, name, get, set, setVerifyHelp
return attributesCorrect;
}
SimpleTestAPIs.append(accessorPropertyAttributesAreCorrect);
SimpleTestAPIs.push(accessorPropertyAttributesAreCorrect);
//-----------------------------------------------------------------------------
var PickledSimpleTestAPIs = SimpleTestAPIs.join(" ");

View File

@ -91,20 +91,12 @@ function BrowserRunner() {
// Set up some globals.
win.testRun = testRun;
win.testFinished = testFinished;
win.fnSupportsStrict = fnSupportsStrict;
win.fnExists = fnExists;
win.ConvertToFileUrl = ConvertToFileUrl;
win.fnSupportsArrayIndexGettersOnObjects = fnSupportsArrayIndexGettersOnObjects;
win.fnSupportsArrayIndexGettersOnArrays = fnSupportsArrayIndexGettersOnArrays;
win.arrayContains = arrayContains;
win.compareArray = compareArray;
//TODO: these should be moved to sta.js
win.SputnikError = SputnikError;
win.$ERROR = $ERROR;
win.$FAIL = $FAIL;
win.$PRINT = function () {};
win.$INCLUDE = function() {};
win.dataPropertyAttributesAreCorrect = dataPropertyAttributesAreCorrect;
win.accessorPropertyAttributesAreCorrect = accessorPropertyAttributesAreCorrect;
if(includes !== null) {
// We have some includes, so loop through each include and pull in the dependencies.
@ -125,6 +117,10 @@ function BrowserRunner() {
}
}
//Write out all of our helper functions
doc.writeln("<script type='text/javascript'>" + PickledSimpleTestAPIs + "</script>");
// Write ES5Harness.registerTest and fnGlobalObject, which returns the global object, and the testFinished call.
doc.writeln("<script type='text/javascript'>ES5Harness = {};" +
"function fnGlobalObject() { return window; }" +
@ -243,6 +239,8 @@ function Controller() {
var runner = new BrowserRunner();
var loader = new TestLoader();
var controller = this;
var startTime;
var elapsed = 0;
runner.onComplete = function(test) {
presenter.addTestResult(test);
@ -268,21 +266,28 @@ function Controller() {
loader.onTestsExhausted = function() {
state = 'stopped';
presenter.finished();
elapsed += new Date() - startTime;
elapsed = elapsed/(1000*60); //minutes
elapsed = elapsed.toFixed(1);
presenter.finished(elapsed);
}
this.start = function() {
state = 'running';
startTime = new Date();
loader.getNextTest();
presenter.started();
}
this.pause = function() {
elapsed += new Date() - startTime;
state = 'paused';
presenter.paused();
}
this.reset = function() {
startTime = new Date();
elapsed = 0;
loader.reset();
presenter.reset();
}