Bug 988169 - display the list of mochitests again; r=jmaher
authorNathan Froyd <froydnj@mozilla.com>
Thu, 22 May 2014 10:32:32 -0400
changeset 206902 f68a689a35931d5d98b11e33255fc9c1a1e676a7
parent 206901 4cc3b00d4ece49b0f34e19cd6f317631e27e6dab
child 206903 0f4eb14fcbd82aa5535d6f5371376b0655b05bb8
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs988169
milestone32.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 988169 - display the list of mochitests again; r=jmaher
testing/mochitest/server.js
--- a/testing/mochitest/server.js
+++ b/testing/mochitest/server.js
@@ -568,28 +568,57 @@ function regularListing(metadata, respon
         A({href: ".."}, "Up a level"),
         UL(linksToListItems(links))
       )
     )
   );
 }
 
 /**
+ * Read a manifestFile located at the root of the server's directory and turn
+ * it into an object for creating a table of clickable links for each test.
+ */
+function convertManifestToTestLinks(root, manifest)
+{
+  Cu.import("resource://gre/modules/NetUtil.jsm");
+
+  var manifestFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
+  manifestFile.initWithFile(serverBasePath);
+  manifestFile.append(manifest);
+
+  var manifestStream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
+  manifestStream.init(manifestFile, -1, 0, 0);
+
+  var manifestObj = JSON.parse(NetUtil.readInputStreamToString(manifestStream,
+                                                               manifestStream.available()));
+  var paths = manifestObj.tests;
+  var pathPrefix = '/' + root + '/'
+  return [paths.reduce(function(t, p) { t[pathPrefix + p.path] = true; return t; }, {}),
+          paths.length];
+}
+
+/**
  * Produce a test harness page containing all the test cases
  * below it, recursively.
  */
 function testListing(metadata, response)
 {
   var links = {};
   var count = 0;
   if (metadata.queryString.indexOf('manifestFile') == -1) {
     [links, count] = list(metadata.path,
                           metadata.getProperty("directory"),
                           true);
+  } else if (typeof(Components) != undefined) {
+    var manifest = metadata.queryString.match(/manifestFile=([^&]+)/)[1];
+
+    [links, count] = convertManifestToTestLinks(metadata.path.split('/')[1],
+                                                manifest);
   }
+
   var table_class = metadata.queryString.indexOf("hideResultsTable=1") > -1 ? "invisible": "";
 
   let testname = (metadata.queryString.indexOf("testname=") > -1)
                  ? metadata.queryString.match(/testname=([^&]+)/)[1]
                  : "";
 
   dumpn("count: " + count);
   var tests = testname