Bug 1468634 - Allow running a single APZ mochitest subtest at a time. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Sat, 16 Jun 2018 21:28:05 -0400
changeset 808036 a969553edfd0bd46b9ff0be695af621cf3e10bff
parent 808035 589175a107b23644bf61af82a2f72fc4e48b6f8e
push id113259
push userbballo@mozilla.com
push dateSun, 17 Jun 2018 19:39:52 +0000
reviewerskats
bugs1468634
milestone62.0a1
Bug 1468634 - Allow running a single APZ mochitest subtest at a time. r=kats This is done by passing "--setpref apz.subtest=<subtest-name>" on the mochitest command line, where <subtest-name> is the name of the subtest file (including the extension). MozReview-Commit-ID: EscFekIeOxr
gfx/layers/apz/test/mochitest/apz_test_utils.js
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -189,16 +189,20 @@ function waitForApzFlushedRepaints(aCall
 // functions provided by SimpleTest are also mapped into the subtest's window.
 // For other things from the parent, the subtest can use window.opener.<whatever>
 // to access objects.
 function runSubtestsSeriallyInFreshWindows(aSubtests) {
   return new Promise(function(resolve, reject) {
     var testIndex = -1;
     var w = null;
 
+    // If the "apz.subtest" pref has been set, only a single subtest whose name matches
+    // the pref's value (if any) will be run.
+    var onlyOneSubtest = SpecialPowers.getCharPref("apz.subtest", /* default = */ "");
+
     function advanceSubtestExecution() {
       var test = aSubtests[testIndex];
       if (w) {
         // Run any cleanup functions registered in the subtest
         if (w.ApzCleanup) { // guard against the subtest not loading apz_test_utils.js
           w.ApzCleanup.execute();
         }
         if (typeof test.dp_suppression != 'undefined') {
@@ -221,16 +225,23 @@ function runSubtestsSeriallyInFreshWindo
 
       testIndex++;
       if (testIndex >= aSubtests.length) {
         resolve();
         return;
       }
 
       test = aSubtests[testIndex];
+
+      if (onlyOneSubtest && onlyOneSubtest != test.file) {
+        SimpleTest.ok(true, "Skipping " + test.file + " because only " + onlyOneSubtest + " is being run");
+        setTimeout(function() { advanceSubtestExecution(); }, 0);
+        return;
+      }
+
       if (typeof test.dp_suppression != 'undefined') {
         // Normally during a test, the displayport will get suppressed during page
         // load, and unsuppressed at a non-deterministic time during the test. The
         // unsuppression can trigger a repaint which interferes with the test, so
         // to avoid that we can force the displayport to be unsuppressed for the
         // entire test which is more deterministic.
         SpecialPowers.getDOMWindowUtils(window).respectDisplayPortSuppression(test.dp_suppression);
       }