Bug 375543. Add better diagnostics to failures. Patch by John Resig. r=sayrer
--- a/dom/tests/mochitest/ajax/prototype/test/lib/unittest.js
+++ b/dom/tests/mochitest/ajax/prototype/test/lib/unittest.js
@@ -270,17 +270,25 @@ Test.Unit.Assertions.prototype = {
}
return div;
},
pass: function() {
this.assertions++;
},
fail: function(message) {
this.failures++;
- this.messages.push("Failure: " + message);
+
+ var line = "";
+ try {
+ throw new Error("stack");
+ } catch(e){
+ line = (/\.html:(\d+)/.exec(e.stack || '') || ['',''])[1];
+ }
+
+ this.messages.push("Failure: " + message + (line ? " Line #" + line : ""));
},
info: function(message) {
this.messages.push("Info: " + message);
},
error: function(error, test) {
this.errors++;
this.actions['retry with throw'] = function() { test.run(true) };
this.messages.push(error.name + ": "+ error.message + "(" + Test.Unit.inspect(error) + ")");