Bug 443090 - Unify unittest failures (xpcshell part) p=ted.mielczarek, r=bsmedberg
authorNick Thomas <nrthomas@gmail.com>
Wed, 16 Jul 2008 17:45:42 +1200
changeset 15962 d3f2561990ab0bea2190664b9ddf7c548cca06fa
parent 15961 b2d1c3093a84bac8fc6a08d7c9b6df6e358003ec
child 15963 03a87160d7a20bbb10d689fc1dfb3bcd8ca8ec4a
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs443090
milestone1.9.1a1pre
Bug 443090 - Unify unittest failures (xpcshell part) p=ted.mielczarek, r=bsmedberg
tools/test-harness/xpcshell-simple/head.js
tools/test-harness/xpcshell-simple/test_all.sh
--- a/tools/test-harness/xpcshell-simple/head.js
+++ b/tools/test-harness/xpcshell-simple/head.js
@@ -87,44 +87,54 @@ function _do_quit() {
 /************** Functions to be used from the tests **************/
 
 function do_timeout(delay, expr) {
   var timer = Components.classes["@mozilla.org/timer;1"]
                         .createInstance(Components.interfaces.nsITimer);
   timer.initWithCallback(new _TimerCallback(expr), delay, timer.TYPE_ONE_SHOT);
 }
 
-function do_throw(text) {
+function do_throw(text, stack) {
+  if (!stack)
+    stack = Components.stack.caller;
   _fail = true;
   _do_quit();
-  dump("*** CHECK FAILED: " + text + "\n");
+  dump("*** TEST-UNEXPECTED-FAIL | " + stack.filename + " | " + text + "\n");
   var frame = Components.stack;
   while (frame != null) {
     dump(frame + "\n");
     frame = frame.caller;
   }
   throw Components.results.NS_ERROR_ABORT;
 }
 
-function do_check_neq(left, right) {
+function do_check_neq(left, right, stack) {
+  if (!stack)
+    stack = Components.stack.caller;
   if (left == right)
-    do_throw(left + " != " + right);
+    do_throw(left + " != " + right, stack);
 }
 
-function do_check_eq(left, right) {
+function do_check_eq(left, right, stack) {
+  if (!stack)
+    stack = Components.stack.caller;
   if (left != right)
-    do_throw(left + " == " + right);
+    do_throw(left + " == " + right, stack);
 }
 
-function do_check_true(condition) {
-  do_check_eq(condition, true);
+function do_check_true(condition, stack) {
+  if (!stack)
+    stack = Components.stack.caller;
+  do_check_eq(condition, true, stack);
 }
 
-function do_check_false(condition) {
-  do_check_eq(condition, false);
+function do_check_false(condition, stack) {
+  if (!stack)
+    stack = Components.stack.caller;
+  do_check_eq(condition, false, stack);
 }
 
 function do_test_pending() {
   dump("*** test pending\n");
   _tests_pending++;
 }
 
 function do_test_finished() {
--- a/tools/test-harness/xpcshell-simple/test_all.sh
+++ b/tools/test-harness/xpcshell-simple/test_all.sh
@@ -105,27 +105,26 @@ done
 
 
 #################
 # RUN EACH TEST #
 #################
 
 for t in $testdir/test_*.js
 do
-    echo -n "$t: "
     NATIVE_TOPSRCDIR="$native_topsrcdir" TOPSRCDIR="$topsrcdir" $xpcshell -s $headfiles -f $t $tailfiles 2> $t.log 1>&2
     rv="$?"
     if [ ! "$rv" = "0"  -o \
          `grep -c '\*\*\* PASS' $t.log` = 0 ]
     then
-        echo "FAIL"
+        echo "TEST-UNEXPECTED-FAIL | $t | test failed, see log"
         echo "$t.log:"
         echo ">>>>>>>"
         cat $t.log
         echo ""
         echo "<<<<<<<"
         exit_status=1
     else
-        echo "PASS"
+        echo "TEST-PASS | $t | all tests passed"
     fi
 done
 
 exit $exit_status