Bug 1142734: Add additional logging to jetpack-addons tests. r=erikvold
authorDave Townsend <dtownsend@oxymoronical.com>
Fri, 13 Mar 2015 09:52:25 -0700
changeset 233847 6c269cbf361c75a3d6c48ab3777b8462e0649c8f
parent 233846 75dc344c04d189bdf81624f2734f03c099b127f1
child 233848 b8b1d58af8c670684b18660ad5f6d6af50031047
push id28425
push usercbook@mozilla.com
push dateTue, 17 Mar 2015 10:33:06 +0000
treeherdermozilla-central@a194e8023090 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserikvold
bugs1142734
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1142734: Add additional logging to jetpack-addons tests. r=erikvold
testing/mochitest/jetpack-addon-harness.js
--- a/testing/mochitest/jetpack-addon-harness.js
+++ b/testing/mochitest/jetpack-addon-harness.js
@@ -21,16 +21,22 @@ window.addEventListener("load", function
   window.addEventListener("MozAfterPaint", function testOnMozAfterPaint() {
     window.removeEventListener("MozAfterPaint", testOnMozAfterPaint);
     setTimeout(testInit, 0);
   });
 });
 
 let sdkpath = null;
 
+// Strip off the chrome prefix to get the actual path of the test directory
+function realPath(chrome) {
+  return chrome.substring("chrome://mochitests/content/jetpack-addon/".length)
+               .replace(".xpi", "");
+}
+
 // Installs a single add-on returning a promise for when install is completed
 function installAddon(url) {
   return new Promise(function(resolve, reject) {
     AddonManager.getInstallForURL(url, function(install) {
       install.addListener({
         onDownloadEnded: function(install) {
           // Set add-on's test options
           const options = {
@@ -63,18 +69,22 @@ function installAddon(url) {
             setPrefs("extensions.modules." + install.addon.id + ".path", paths);
           }
         },
 
         onInstallEnded: function(install, addon) {
           resolve(addon);
         },
 
+        onDownloadFailed: function(install) {
+          reject("Download failed: " + install.error);
+        },
+
         onInstallFailed: function(install) {
-          reject();
+          reject("Install failed: " + install.error);
         }
       });
 
       install.install();
     }, "application/x-xpinstall");
   });
 }
 
@@ -105,20 +115,25 @@ function waitForResults() {
 
       resolve(JSON.parse(data));
     }, "sdk:test:results", false);
   });
 }
 
 // Runs tests for the add-on available at URL.
 let testAddon = Task.async(function*({ url, expected }) {
+  dump("TEST-INFO | jetpack-addon-harness.js | Installing test add-on " + realPath(url) + "\n");
   let addon = yield installAddon(url);
+
   let results = yield waitForResults();
+
+  dump("TEST-INFO | jetpack-addon-harness.js | Uninstalling test add-on " + realPath(url) + "\n");
   yield uninstallAddon(addon);
 
+  dump("TEST-INFO | jetpack-addon-harness.js | Testing add-on " + realPath(url) + " is complete\n");
   return results;
 });
 
 // Sets a set of prefs for test add-ons
 function setPrefs(root, options) {
   Object.keys(options).forEach(id => {
     const key = root + "." + id;
     const value = options[id]
@@ -191,19 +206,26 @@ function testInit() {
       function testNextAddon() {
         if (fileNames.length == 0)
           return finish();
 
         let filename = fileNames.shift();
         testAddon(filename).then(results => {
           passed += results.passed;
           failed += results.failed;
-        }).then(testNextAddon);
+        }).then(testNextAddon, error => {
+          // If something went wrong during the test then a previous test add-on
+          // may still be installed, this leaves us in an unexpected state so
+          // probably best to just abandon testing at this point
+          failed++;
+          dump("TEST-UNEXPECTED-FAIL | jetpack-addon-harness.js | Error testing " + realPath(filename.url) + ": " + error + "\n");
+          finish();
+        });
       }
 
       testNextAddon();
     }
     catch (e) {
-      dump("TEST-UNEXPECTED-FAIL: jetpack-addon-harness.js | error starting test harness (" + e + ")\n");
+      dump("TEST-UNEXPECTED-FAIL | jetpack-addon-harness.js | error starting test harness (" + e + ")\n");
       dump(e.stack);
     }
   });
 }