Bug 443090 - Unify unittest failures (browser chrome and mochitest part) p=ted.mielczarek, r=gavin.sharp

This commit is contained in:
Nick Thomas 2008-07-16 17:43:15 +12:00
parent 9203b7a577
commit 30904f2e02
3 changed files with 38 additions and 38 deletions

View File

@ -125,9 +125,7 @@
get log() {
var path = this.path;
return this.tests.map(function (t) {
if (!t.pass)
return t.msg + " - " + path;
return t.msg;
return t.result + " | " + path + " | " + t.msg;
}).join("\n");
}
};
@ -182,7 +180,7 @@
function getLogFromTests(aTests) {
if (!aTests.length)
return "PASS - No tests to run";
return "TEST-PASS | | No tests to run";
var log = aTests.map(function (f) {
var output = f.path + "\n";

View File

@ -38,7 +38,7 @@ Tester.prototype = {
step: function Tester_step() {
this.currentTestIndex++;
},
start: function Tester_start() {
this.execTest();
},
@ -91,18 +91,19 @@ function testResult(aCondition, aName, aDiag, aIsTodo) {
this.pass = !!aCondition;
this.todo = aIsTodo;
this.msg = aName;
if (this.pass) {
if (aIsTodo)
this.msg = "\tTODO PASS - " + aName;
this.result = "TEST-KNOWN-FAIL";
else
this.msg = "\tPASS - " + aName;
this.result = "TEST-PASS";
} else {
this.msg = "\tFAIL - ";
if (aIsTodo)
this.msg += "TODO Worked? - ";
this.msg += aName;
if (aDiag)
this.msg += " - " + aDiag;
if (aIsTodo)
this.result = "TEST-UNEXPECTED-PASS";
else
this.result = "TEST-UNEXPECTED-FAIL";
}
}
@ -116,29 +117,29 @@ function testScope(aTests) {
var self = this;
this.ok = function test_ok(condition, name, diag) {
self.tests.push(new testResult(condition, name, diag, false));
}
};
this.is = function test_is(a, b, name) {
self.ok(a == b, name, "Got " + a + ", expected " + b);
}
};
this.isnot = function test_isnot(a, b, name) {
self.ok(a != b, name, "Didn't expect " + a + ", but got it");
}
};
this.todo = function test_todo(condition, name, diag) {
self.tests.push(new testResult(!condition, name, diag, true));
}
};
this.todo_is = function test_todo_is(a, b, name) {
self.todo(a == b, name, "Got " + a + ", expected " + b);
},
};
this.todo_isnot = function test_todo_isnot(a, b, name) {
self.todo(a != b, name, "Didn't expect " + a + ", but got it");
},
};
this.waitForExplicitFinish = function test_WFEF() {
self.done = false;
}
};
this.finish = function test_finish() {
self.done = true;
}
};
}
testScope.prototype = {
done: true,
@ -165,7 +166,7 @@ resultPoller.prototype = {
var self = this;
function checkDone() {
self.loopCount++;
if (self.loopCount > MAX_LOOP_COUNT) {
self.test.tests.push(new testResult(false, "Timed out", "", false));
self.test.scope.done = true;
@ -176,7 +177,7 @@ resultPoller.prototype = {
// Notify the callback
self.callback();
self.callback = null;
self.callback = null;
self.test = null;
}
}

View File

@ -5,7 +5,7 @@
*
* Test.Simple doesn't work on IE < 6.
* TODO:
* * Support the Test.Simple API used by MochiKit, to be able to test MochiKit
* * Support the Test.Simple API used by MochiKit, to be able to test MochiKit
* itself against IE 5.5
*
**/
@ -36,7 +36,7 @@ SimpleTest._stopOnLoad = true;
SimpleTest.ok = function (condition, name, diag) {
var test = {'result': !!condition, 'name': name, 'diag': diag || ""};
if (SimpleTest._logEnabled)
SimpleTest._logResult(test, "PASS", "FAIL");
SimpleTest._logResult(test, "TEST-PASS", "TEST-UNEXPECTED-FAIL");
SimpleTest._tests.push(test);
};
@ -58,30 +58,31 @@ SimpleTest.isnot = function (a, b, name) {
SimpleTest.todo = function(condition, name, diag) {
var test = {'result': !!condition, 'name': name, 'diag': diag || "", todo: true};
if (SimpleTest._logEnabled)
SimpleTest._logResult(test, "TODO WORKED?", "TODO");
SimpleTest._logResult(test, "TEST-UNEXPECTED-PASS", "TEST-KNOWN-FAIL");
SimpleTest._tests.push(test);
}
};
SimpleTest._logResult = function(test, passString, failString) {
var msg = test.result ? passString : failString;
msg += " | " + test.name;
var url = "";
msg += " | ";
if (parentRunner.currentTestURL)
url = " | " + parentRunner.currentTestURL;
msg += parentRunner.currentTestURL;
msg += " | " + test.name;
var diag = "";
if (test.diag)
diag = " - " + test.diag;
if (test.result) {
if (test.todo)
parentRunner.logger.error(msg + url)
parentRunner.logger.error(msg + diag);
else
parentRunner.logger.log(msg);
} else {
msg += " | " + test.diag;
if (test.todo)
parentRunner.logger.log(msg)
parentRunner.logger.log(msg);
else
parentRunner.logger.error(msg + url);
parentRunner.logger.error(msg + diag);
}
}
};
/**
* Copies of is and isnot with the call to ok replaced by a call to todo.
@ -111,7 +112,7 @@ SimpleTest.report = function () {
var cls, msg;
if (test.todo && !test.result) {
todo++;
cls = "test_todo"
cls = "test_todo";
msg = "todo - " + test.name + " " + test.diag;
} else if (test.result &&!test.todo) {
passed++;
@ -201,7 +202,7 @@ SimpleTest.waitForExplicitFinish = function () {
};
/**
* Talks to the TestRunner if being ran on a iframe and the parent has a
* Talks to the TestRunner if being ran on a iframe and the parent has a
* TestRunner object.
**/
SimpleTest.talkToRunner = function () {
@ -211,7 +212,7 @@ SimpleTest.talkToRunner = function () {
};
/**
* Finishes the tests. This is automatically called, except when
* Finishes the tests. This is automatically called, except when
* SimpleTest.waitForExplicitFinish() has been invoked.
**/
SimpleTest.finish = function () {
@ -379,7 +380,7 @@ SimpleTest._formatStack = function (stack) {
out += vars[0] + ' = ' + vals[0] + SimpleTest.LF;
out += vars[1] + ' = ' + vals[1] + SimpleTest.LF;
return ' ' + out;
};