Bug 1391694 - Avoid false shutdown leaks in browser-chrome tests with --repeat; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Fri, 15 Sep 2017 07:29:44 -0600
changeset 433109 670be1db5eeddc43fb7a36342f1c97bf6c3a5103
parent 433108 ee8939119c172f5e2c4b101ed17a23ea35897782
child 433110 8384b2a43a1bbbdb6468483d55d2331ddd1cf2ab
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1391694
milestone57.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 1391694 - Avoid false shutdown leaks in browser-chrome tests with --repeat; r=jmaher This patch re-organizes control flow in the browser-chrome harness so that extra memory cleanup only happens just before the browser is closed, even when running with --repeat.
testing/mochitest/browser-test.js
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -207,17 +207,17 @@ Tester.prototype = {
   lastStartTime: null,
   lastAssertionCount: 0,
   failuresFromInitialWindowState: 0,
 
   get currentTest() {
     return this.tests[this.currentTestIndex];
   },
   get done() {
-    return this.currentTestIndex == this.tests.length - 1;
+    return (this.currentTestIndex == this.tests.length - 1) && (this.repeat <= 0);
   },
 
   start: function Tester_start() {
     TabDestroyObserver.init();
 
     //if testOnLoad was not called, then gConfig is not defined
     if (!gConfig)
       gConfig = readConfig();
@@ -331,50 +331,44 @@ Tester.prototype = {
   finish: function Tester_finish(aSkipSummary) {
     var passCount = this.tests.reduce((a, f) => a + f.passCount, 0);
     var failCount = this.tests.reduce((a, f) => a + f.failCount, 0);
     var todoCount = this.tests.reduce((a, f) => a + f.todoCount, 0);
 
     // Include failures from window state checking prior to running the first test
     failCount += this.failuresFromInitialWindowState;
 
-    if (this.repeat > 0) {
-      --this.repeat;
-      this.currentTestIndex = -1;
-      this.nextTest();
-    } else {
-      TabDestroyObserver.destroy();
-      Services.console.unregisterListener(this);
+    TabDestroyObserver.destroy();
+    Services.console.unregisterListener(this);
+
+    // It's important to terminate the module to avoid crashes on shutdown.
+    this.PromiseTestUtils.uninit();
 
-      // It's important to terminate the module to avoid crashes on shutdown.
-      this.PromiseTestUtils.uninit();
+    // In the main process, we print the ShutdownLeaksCollector message here.
+    let pid = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).processID;
+    dump("Completed ShutdownLeaks collections in process " + pid + "\n");
 
-      // In the main process, we print the ShutdownLeaksCollector message here.
-      let pid = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).processID;
-      dump("Completed ShutdownLeaks collections in process " + pid + "\n");
-
-      this.structuredLogger.info("TEST-START | Shutdown");
+    this.structuredLogger.info("TEST-START | Shutdown");
 
-      if (this.tests.length) {
-        let e10sMode = gMultiProcessBrowser ? "e10s" : "non-e10s";
-        this.structuredLogger.info("Browser Chrome Test Summary");
-        this.structuredLogger.info("Passed:  " + passCount);
-        this.structuredLogger.info("Failed:  " + failCount);
-        this.structuredLogger.info("Todo:    " + todoCount);
-        this.structuredLogger.info("Mode:    " + e10sMode);
-      } else {
-        this.structuredLogger.error("browser-test.js | No tests to run. Did you pass invalid test_paths?");
-      }
-      this.structuredLogger.info("*** End BrowserChrome Test Results ***");
+    if (this.tests.length) {
+      let e10sMode = gMultiProcessBrowser ? "e10s" : "non-e10s";
+      this.structuredLogger.info("Browser Chrome Test Summary");
+      this.structuredLogger.info("Passed:  " + passCount);
+      this.structuredLogger.info("Failed:  " + failCount);
+      this.structuredLogger.info("Todo:    " + todoCount);
+      this.structuredLogger.info("Mode:    " + e10sMode);
+    } else {
+      this.structuredLogger.error("browser-test.js | No tests to run. Did you pass invalid test_paths?");
+    }
+    this.structuredLogger.info("*** End BrowserChrome Test Results ***");
 
-      // Tests complete, notify the callback and return
-      this.callback(this.tests);
-      this.callback = null;
-      this.tests = null;
-    }
+    // Tests complete, notify the callback and return
+    this.callback(this.tests);
+    this.callback = null;
+    this.tests = null;
   },
 
   haltTests: function Tester_haltTests() {
     // Do not run any further tests
     this.currentTestIndex = this.tests.length - 1;
     this.repeat = 0;
   },
 
@@ -685,18 +679,28 @@ Tester.prototype = {
               });
             }, 1000);
           });
         });
 
         return;
       }
 
-      this.currentTestIndex++;
-      this.execTest();
+      if (this.repeat > 0) {
+        --this.repeat;
+        if (this.currentTestIndex < 0) {
+          this.currentTestIndex = 0;
+        }
+        this.execTest();
+      } else {
+        this.currentTestIndex++;
+        if (gConfig.repeat)
+          this.repeat = gConfig.repeat;
+        this.execTest();
+      }
     });
   }),
 
   execTest: function Tester_execTest() {
     this.structuredLogger.testStart(this.currentTest.path);
 
     this.SimpleTest.reset();