Bug 375543. Add better diagnostics to failures. Patch by John Resig. r=sayrer
authorsayrer@gmail.com
Wed, 08 Aug 2007 22:48:58 -0700
changeset 4405 87e59cd5f726df3db4a62532f559515bb88d50e2
parent 4404 afad85892e76d89d47b1ff8147e9d068850523b4
child 4406 3a80378cb9a458b67d0a53f51e9cb5feec42f1d7
push idunknown
push userunknown
push dateunknown
reviewerssayrer
bugs375543
milestone1.9a8pre
Bug 375543. Add better diagnostics to failures. Patch by John Resig. r=sayrer
dom/tests/mochitest/ajax/prototype/test/lib/unittest.js
--- 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) + ")");