Bug 1065446 - Simplify and document running browser_parsable_script.js in debug builds. r=Gijs
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Fri, 12 Sep 2014 09:10:35 +0100
changeset 205143 3f3e0c97c988d14c273e67d3f512261876a9a253
parent 205142 358914066f472301558c002b53ba114b057af37d
child 205144 9aae4c1be901302c98f2743435ea70d4dd886bb8
push id49106
push userphilringnalda@gmail.com
push dateSat, 13 Sep 2014 17:12:34 +0000
treeherdermozilla-inbound@ab04d0f2665f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1065446
milestone35.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 1065446 - Simplify and document running browser_parsable_script.js in debug builds. r=Gijs
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_parsable_script.js
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -352,17 +352,17 @@ skip-if = buildapp == 'mulet' || e10s # 
 [browser_pageInfo.js]
 skip-if = buildapp == 'mulet' || e10s # Bug 866413 - PageInfo doesn't work in e10s
 [browser_page_style_menu.js]
 skip-if = e10s # Bug ?????? - test directly manipulates content
 
 [browser_parsable_css.js]
 skip-if = e10s
 [browser_parsable_script.js]
-skip-if = debug || asan # Times out on debug/asan, and we are less picky about our JS there
+skip-if = asan # Disabled because it takes a long time (see test for more information)
 
 [browser_pinnedTabs.js]
 [browser_plainTextLinks.js]
 skip-if = e10s # Bug ?????? - test directly manipulates content (creates and fetches elements directly from content document)
 [browser_popupUI.js]
 skip-if = buildapp == 'mulet' || e10s # Bug ?????? - test directly manipulates content (tries to get a popup element directly from content)
 [browser_printpreview.js]
 skip-if = buildapp == 'mulet' || e10s # Bug ?????? - timeout after logging "Error: Channel closing: too late to send/recv, messages will be lost"
--- a/browser/base/content/test/general/browser_parsable_script.js
+++ b/browser/base/content/test/general/browser_parsable_script.js
@@ -55,28 +55,68 @@ function parsePromise(uri) {
     };
     xhr.overrideMimeType("application/javascript");
     xhr.send(null);
   });
   return promise;
 }
 
 add_task(function* checkAllTheJS() {
-  let appDir = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
-  // This asynchronously produces a list of URLs (sadly, mostly sync on our
-  // test infrastructure because it runs against jarfiles there, and
-  // our zipreader APIs are all sync)
-  let uris = yield generateURIsFromDirTree(appDir, [".js", ".jsm"]);
+  // In debug builds, even on a fast machine, collecting the file list may take
+  // more than 30 seconds, and parsing all files may take four more minutes.
+  // For this reason, this test must be explictly requested in debug builds by
+  // using the "--setpref parse=<filter>" argument to mach.  You can specify:
+  //  - A case-sensitive substring of the file name to test (slow).
+  //  - A single absolute URI printed out by a previous run (fast).
+  //  - An empty string to run the test on all files (slowest).
+  let parseRequested = Services.prefs.prefHasUserValue("parse");
+  let parseValue = parseRequested && Services.prefs.getCharPref("parse");
+  if (SpecialPowers.isDebugBuild) {
+    if (!parseRequested) {
+      ok(true, "Test disabled on debug build. To run, execute: ./mach" +
+               " mochitest-browser --setpref parse=<case_sensitive_filter>" +
+               " browser/base/content/test/general/browser_parsable_script.js");
+      return;
+    }
+    // Request a 10 minutes timeout (30 seconds * 20) for debug builds.
+    requestLongerTimeout(20);
+  }
+
+  let uris;
+  // If an absolute URI is specified on the command line, use it immediately.
+  if (parseValue && parseValue.contains(":")) {
+    uris = [NetUtil.newURI(parseValue)];
+  } else {
+    let appDir = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
+    // This asynchronously produces a list of URLs (sadly, mostly sync on our
+    // test infrastructure because it runs against jarfiles there, and
+    // our zipreader APIs are all sync)
+    let startTimeMs = Date.now();
+    info("Collecting URIs");
+    uris = yield generateURIsFromDirTree(appDir, [".js", ".jsm"]);
+    info("Collected URIs in " + (Date.now() - startTimeMs) + "ms");
+
+    // Apply the filter specified on the command line, if any.
+    if (parseValue) {
+      uris = uris.filter(uri => {
+        if (uri.spec.contains(parseValue)) {
+          return true;
+        }
+        info("Not checking filtered out " + uri.spec);
+        return false;
+      });
+    }
+  }
 
   // We create an array of promises so we can parallelize all our parsing
   // and file loading activity:
   let allPromises = [];
   for (let uri of uris) {
     if (uriIsWhiteListed(uri)) {
-      info("Not checking " + uri.spec);
+      info("Not checking whitelisted " + uri.spec);
       continue;
     }
     allPromises.push(parsePromise(uri.spec));
   }
 
   let promiseResults = yield Promise.all(allPromises);
   is(promiseResults.filter((x) => !x).length, 0, "There should be 0 parsing errors");
 });