Bug 863311: Include test function name in test pending / test finished messages. r=ted.mielczarek
authorIrving Reid <irving@mozilla.com>
Fri, 03 May 2013 12:08:30 -0400
changeset 130757 be579e9be3e4cf54b9f006fbc6f31363d18a3b3f
parent 130756 4768761daaef02ad8aba3e16e4f14c8d018712e6
child 130758 06cb02df9a67e5661cc7b0b368449f2e82ea99d6
push id1579
push userphilringnalda@gmail.com
push dateSat, 04 May 2013 04:38:04 +0000
treeherderfx-team@a56432a42a41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs863311
milestone23.0a1
Bug 863311: Include test function name in test pending / test finished messages. r=ted.mielczarek
testing/xpcshell/head.js
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -327,19 +327,19 @@ function _execute_test() {
   });
 
   // _HEAD_FILES is dynamically defined by <runxpcshelltests.py>.
   _load_files(_HEAD_FILES);
   // _TEST_FILE is dynamically defined by <runxpcshelltests.py>.
   _load_files(_TEST_FILE);
 
   try {
-    do_test_pending();
+    do_test_pending("MAIN run_test");
     run_test();
-    do_test_finished();
+    do_test_finished("MAIN run_test");
     _do_main();
   } catch (e) {
     _passed = false;
     // do_check failures are already logged and set _quit to true and throw
     // NS_ERROR_ABORT. If both of those are true it is likely this exception
     // has already been logged so there is no need to log it again. It's
     // possible that this will mask an NS_ERROR_ABORT that happens after a
     // do_check failure though.
@@ -423,18 +423,19 @@ function do_print(msg) {
  *   the number of milliseconds to delay
  * @param callback : function() : void
  *   the function to call
  */
 function do_timeout(delay, func) {
   new _Timer(func, Number(delay));
 }
 
-function do_execute_soon(callback) {
-  do_test_pending();
+function do_execute_soon(callback, aName) {
+  let funcName = (aName ? aName : callback.name);
+  do_test_pending(funcName);
   var tm = Components.classes["@mozilla.org/thread-manager;1"]
                      .getService(Components.interfaces.nsIThreadManager);
 
   tm.mainThread.dispatch({
     run: function() {
       try {
         callback();
       } catch (e) {
@@ -451,17 +452,17 @@ function do_execute_soon(callback) {
           }
           else {
             dump("\n");
           }
           _do_quit();
         }
       }
       finally {
-        do_test_finished();
+        do_test_finished(funcName);
       }
     }
   }, Components.interfaces.nsIThread.DISPATCH_NORMAL);
 }
 
 function do_throw(text, stack) {
   if (!stack)
     stack = Components.stack.caller;
@@ -780,26 +781,26 @@ function format_pattern_match_failure(di
     a = diagnosis;
   } else if (diagnosis.property) {
     a = "Property " + uneval(diagnosis.property) + " of object didn't match:\n";
     a += format_pattern_match_failure(diagnosis.diagnosis, indent + "  ");
   }
   return indent + a;
 }
 
-function do_test_pending() {
+function do_test_pending(aName) {
   ++_tests_pending;
 
-  _dump("TEST-INFO | (xpcshell/head.js) | test " + _tests_pending +
-         " pending\n");
+  _dump("TEST-INFO | (xpcshell/head.js) | test" + (aName ? " " + aName : "") +
+         " pending (" + _tests_pending + ")\n");
 }
 
-function do_test_finished() {
-  _dump("TEST-INFO | (xpcshell/head.js) | test " + _tests_pending +
-         " finished\n");
+function do_test_finished(aName) {
+  _dump("TEST-INFO | (xpcshell/head.js) | test" + (aName ? " " + aName : "") +
+         " finished (" + _tests_pending + ")\n");
 
   if (--_tests_pending == 0)
     _do_quit();
 }
 
 function do_get_file(path, allowNonexistent) {
   try {
     let lf = Components.classes["@mozilla.org/file/directory_service;1"]
@@ -1022,17 +1023,17 @@ function do_load_child_test_harness()
 function run_test_in_child(testFile, optionalCallback) 
 {
   var callback = (typeof optionalCallback == 'undefined') ? 
                     do_test_finished : optionalCallback;
 
   do_load_child_test_harness();
 
   var testPath = do_get_file(testFile).path.replace(/\\/g, "/");
-  do_test_pending();
+  do_test_pending("run in child");
   sendCommand("_dump('CHILD-TEST-STARTED'); "
               + "const _TEST_FILE=['" + testPath + "']; _execute_test(); "
               + "_dump('CHILD-TEST-COMPLETED');", 
               callback);
 }
 
 
 /**
@@ -1104,20 +1105,20 @@ function add_task(func) {
  */
 let _gRunningTest = null;
 let _gTestIndex = 0; // The index of the currently running test.
 function run_next_test()
 {
   function _run_next_test()
   {
     if (_gTestIndex < _gTests.length) {
-      do_test_pending();
       let _isTask;
       [_isTask, _gRunningTest] = _gTests[_gTestIndex++];
       print("TEST-INFO | " + _TEST_FILE + " | Starting " + _gRunningTest.name);
+      do_test_pending(_gRunningTest.name);
 
       if (_isTask) {
         _Task.spawn(_gRunningTest)
              .then(run_next_test, do_report_unexpected_exception);
       } else {
         // Exceptions do not kill asynchronous tests, so they'll time out.
         try {
           _gRunningTest();
@@ -1127,15 +1128,15 @@ function run_next_test()
       }
     }
   }
 
   // For sane stacks during failures, we execute this code soon, but not now.
   // We do this now, before we call do_test_finished(), to ensure the pending
   // counter (_tests_pending) never reaches 0 while we still have tests to run
   // (do_execute_soon bumps that counter).
-  do_execute_soon(_run_next_test);
+  do_execute_soon(_run_next_test, "run_next_test " + _gTestIndex);
 
   if (_gRunningTest !== null) {
     // Close the previous test do_test_pending call.
-    do_test_finished();
+    do_test_finished(_gRunningTest.name);
   }
 }