Skip to content

Commit

Permalink
Bug 1391694 - Avoid false shutdown leaks in browser-chrome tests with…
Browse files Browse the repository at this point in the history
… --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.
  • Loading branch information
gbrownmozilla committed Sep 15, 2017
1 parent 74c6db7 commit 2a451ad
Showing 1 changed file with 36 additions and 32 deletions.
68 changes: 36 additions & 32 deletions testing/mochitest/browser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Tester.prototype = {
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() {
Expand Down Expand Up @@ -336,40 +336,34 @@ Tester.prototype = {
// 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);

// It's important to terminate the module to avoid crashes on shutdown.
this.PromiseTestUtils.uninit();
TabDestroyObserver.destroy();
Services.console.unregisterListener(this);

// 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");
// It's important to terminate the module to avoid crashes on shutdown.
this.PromiseTestUtils.uninit();

this.structuredLogger.info("TEST-START | Shutdown");
// 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");

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 ***");
this.structuredLogger.info("TEST-START | Shutdown");

// Tests complete, notify the callback and return
this.callback(this.tests);
this.callback = null;
this.tests = null;
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;
},

haltTests: function Tester_haltTests() {
Expand Down Expand Up @@ -690,8 +684,18 @@ Tester.prototype = {
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();
}
});
}),

Expand Down

0 comments on commit 2a451ad

Please sign in to comment.