Bug 1301984 - Add code coverage to mochitest-plain tests. r=jmaher
This patch allows the use of the flag '--jscov-dir-prefix' for mochitest plain tests to enable code coverage collection with the JS Debugger. It also enables the mochitest-plain tests for the linux64-jsdcov build platform. MozReview-Commit-ID: 6RqMEZ1I0D7
This commit is contained in:
@@ -96,6 +96,7 @@ ccov-code-coverage-tests:
|
||||
- xpcshell
|
||||
|
||||
jsdcov-code-coverage-tests:
|
||||
- mochitest
|
||||
- mochitest-browser-chrome
|
||||
- mochitest-devtools-chrome
|
||||
- xpcshell
|
||||
|
||||
@@ -354,11 +354,15 @@ marionette:
|
||||
|
||||
mochitest:
|
||||
description: "Mochitest plain run"
|
||||
suite: mochitest/plain-chunked
|
||||
suite:
|
||||
by-test-platform:
|
||||
linux64-jsdcov/opt: mochitest/plain-chunked-coverage
|
||||
default: mochitest/plain-chunked
|
||||
treeherder-symbol: tc-M()
|
||||
loopback-video: true
|
||||
instance-size:
|
||||
by-test-platform:
|
||||
linux64-jsdcov/opt: xlarge
|
||||
android.*: xlarge
|
||||
default: legacy # Bug 1281241: migrating to m3.large instances
|
||||
chunks:
|
||||
@@ -371,11 +375,13 @@ mochitest:
|
||||
e10s:
|
||||
by-test-platform:
|
||||
linux64-ccov/opt: false
|
||||
linux64-jsdcov/opt: false
|
||||
android.*: false
|
||||
default: both
|
||||
max-run-time:
|
||||
by-test-platform:
|
||||
android-4.3-arm7-api-15/debug: 10800
|
||||
linux64-jsdcov/opt: 10800
|
||||
default: 5400
|
||||
allow-software-gl-layers: false
|
||||
mozharness:
|
||||
@@ -402,6 +408,10 @@ mochitest:
|
||||
- unittests/linux_unittest.py
|
||||
- remove_executables.py
|
||||
extra-options:
|
||||
by-test-platform:
|
||||
linux64-jsdcov/opt:
|
||||
- --mochitest-suite=plain-chunked-coverage
|
||||
default:
|
||||
- --mochitest-suite=plain-chunked
|
||||
|
||||
mochitest-a11y:
|
||||
|
||||
@@ -978,6 +978,8 @@ class MochitestDesktop(object):
|
||||
self.urlOpts.append("dumpDMDAfterTest=true")
|
||||
if options.debugger:
|
||||
self.urlOpts.append("interactiveDebugger=true")
|
||||
if options.jscov_dir_prefix:
|
||||
self.urlOpts.append("jscovDirPrefix=%s" % options.jscov_dir_prefix)
|
||||
|
||||
def normflavor(self, flavor):
|
||||
"""
|
||||
|
||||
@@ -108,6 +108,12 @@ TestRunner._numTimeouts = 0;
|
||||
TestRunner._currentTestStartTime = new Date().valueOf();
|
||||
TestRunner._timeoutFactor = 1;
|
||||
|
||||
/**
|
||||
* Used to collect code coverage with the js debugger.
|
||||
*/
|
||||
TestRunner.jscovDirPrefix = "";
|
||||
var coverageCollector = {};
|
||||
|
||||
TestRunner._checkForHangs = function() {
|
||||
function reportError(win, msg) {
|
||||
if ("SimpleTest" in win) {
|
||||
@@ -352,6 +358,12 @@ TestRunner.runTests = function (/*url...*/) {
|
||||
|
||||
SpecialPowers.registerProcessCrashObservers();
|
||||
|
||||
// Initialize code coverage
|
||||
if (TestRunner.jscovDirPrefix != "") {
|
||||
var CoverageCollector = SpecialPowers.Cu.import("resource://testing-common/CoverageUtils.jsm", {}).CoverageCollector;
|
||||
coverageCollector = new CoverageCollector(TestRunner.jscovDirPrefix);
|
||||
}
|
||||
|
||||
TestRunner._urls = flattenArguments(arguments);
|
||||
|
||||
var singleTestRun = this._urls.length <= 1 && TestRunner.repeat <= 1;
|
||||
@@ -483,6 +495,10 @@ TestRunner.runNextTest = function() {
|
||||
TestRunner.onComplete();
|
||||
}
|
||||
TestRunner.generateFailureList();
|
||||
|
||||
if (TestRunner.jscovDirPrefix != "") {
|
||||
coverageCollector.finalize();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -505,6 +521,11 @@ TestRunner.testFinished = function(tests) {
|
||||
TestRunner.updateUI([{ result: false }]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TestRunner.jscovDirPrefix != "") {
|
||||
coverageCollector.recordTestCoverage(TestRunner.currentTestURL);
|
||||
}
|
||||
|
||||
TestRunner._lastTestFinished = TestRunner._currentTest;
|
||||
TestRunner._loopIsRestarting = false;
|
||||
|
||||
|
||||
@@ -144,6 +144,10 @@ if (params.interactiveDebugger) {
|
||||
TestRunner.interactiveDebugger = true;
|
||||
}
|
||||
|
||||
if (params.jscovDirPrefix) {
|
||||
TestRunner.jscovDirPrefix = params.jscovDirPrefix;
|
||||
}
|
||||
|
||||
if (params.maxTimeouts) {
|
||||
TestRunner.maxTimeouts = params.maxTimeouts;
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ config = {
|
||||
"plain-gpu": ["--subsuite=gpu"],
|
||||
"plain-clipboard": ["--subsuite=clipboard"],
|
||||
"plain-chunked": ["--chunk-by-dir=4"],
|
||||
"plain-chunked-coverage": ["--chunk-by-dir=4", "--timeout=1200"],
|
||||
"mochitest-media": ["--subsuite=media"],
|
||||
"chrome": ["--flavor=chrome"],
|
||||
"chrome-gpu": ["--flavor=chrome", "--subsuite=gpu"],
|
||||
|
||||
@@ -399,7 +399,8 @@ class DesktopUnittest(TestingMixin, MercurialScript, BlobUploadMixin, MozbaseMix
|
||||
if suite_category not in c["suite_definitions"]:
|
||||
self.fatal("'%s' not defined in the config!")
|
||||
|
||||
if suite in ('browser-chrome-coverage', 'xpcshell-coverage', 'mochitest-devtools-chrome-coverage'):
|
||||
if suite in ('browser-chrome-coverage', 'xpcshell-coverage',
|
||||
'mochitest-devtools-chrome-coverage', 'plain-chunked-coverage'):
|
||||
base_cmd.append('--jscov-dir-prefix=%s' %
|
||||
dirs['abs_blob_upload_dir'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user