Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1286809 - Provide mechanism to run a subset of tasks in nss-try r…
…=franziskus
- Loading branch information
Tim Taubert
committed
Jul 26, 2016
1 parent
e71e757
commit dce78df
Showing
8 changed files
with
152 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
var intersect = require("intersect"); | ||
var parse_args = require("minimist"); | ||
|
||
function parseOptions(opts) { | ||
opts = parse_args(opts.split(/\s+/), { | ||
default: {build: "do", platform: "all", unittests: "none", tools: "none"}, | ||
alias: {b: "build", p: "platform", u: "unittests", t: "tools"}, | ||
string: ["build", "platform", "unittests", "tools"] | ||
}); | ||
|
||
// Parse build types (d=debug, o=opt). | ||
var builds = intersect(opts.build.split(""), ["d", "o"]); | ||
|
||
// If the given value is nonsense default to debug and opt builds. | ||
if (builds.length == 0) { | ||
builds = ["d", "o"]; | ||
} | ||
|
||
// Parse platforms. | ||
var allPlatforms = ["linux", "linux64", "linux64-asan", "win64"]; | ||
var platforms = intersect(opts.platform.split(/\s*,\s*/), allPlatforms); | ||
|
||
// If the given value is nonsense or "none" default to all platforms. | ||
if (platforms.length == 0 && opts.platform != "none") { | ||
platforms = allPlatforms; | ||
} | ||
|
||
// Parse unit tests. | ||
var allUnitTests = ["crmf", "chains", "cipher", "db", "ec", "fips", "gtest", | ||
"lowhash", "merge", "sdr", "smime", "tools", "ssl"]; | ||
var unittests = intersect(opts.unittests.split(/\s*,\s*/), allUnitTests); | ||
|
||
// If the given value is "all" run all tests. | ||
// If it's nonsense then don't run any tests. | ||
if (opts.unittests == "all") { | ||
unittests = allUnitTests; | ||
} else if (unittests.length == 0) { | ||
unittests = []; | ||
} | ||
|
||
// Parse tools. | ||
var allTools = ["clang-format", "scan-build"]; | ||
var tools = intersect(opts.tools.split(/\s*,\s*/), allTools); | ||
|
||
// If the given value is "all" run all tools. | ||
// If it's nonsense then don't run any tools. | ||
if (opts.tools == "all") { | ||
tools = allTools; | ||
} else if (tools.length == 0) { | ||
tools = []; | ||
} | ||
|
||
return { | ||
builds: builds, | ||
platforms: platforms, | ||
unittests: unittests, | ||
tools: tools | ||
}; | ||
} | ||
|
||
function filterTasks(tasks, comment) { | ||
// Check for try syntax in changeset comment. | ||
var match = comment.match(/^\s*try:\s*(.*)\s*$/); | ||
if (!match) { | ||
return tasks; | ||
} | ||
|
||
var opts = parseOptions(match[1]); | ||
|
||
return tasks.filter(function (task) { | ||
var env = task.task.payload.env || {}; | ||
var th = task.task.extra.treeherder; | ||
var symbol = th.symbol.toLowerCase(); | ||
var machine = th.machine.platform; | ||
var coll = th.collection || {}; | ||
var found; | ||
|
||
// Never include memleak builds, they'll go away soon. | ||
if (coll.memleak) { | ||
return false; | ||
} | ||
|
||
// Filter tools. We can immediately return here as those | ||
// are not affected by platform or build type selectors. | ||
if (machine == "nss-tools") { | ||
return opts.tools.some(function (tool) { | ||
return symbol.startsWith(tool); | ||
}); | ||
} | ||
|
||
// Filter unit tests. | ||
if (env.NSS_TESTS && env.TC_PARENT_TASK_ID) { | ||
found = opts.unittests.some(function (test) { | ||
return symbol.startsWith(test); | ||
}); | ||
|
||
if (!found) { | ||
return false; | ||
} | ||
} | ||
|
||
// Filter by platform. | ||
found = opts.platforms.some(function (platform) { | ||
var aliases = { | ||
"linux": "linux32", | ||
"linux64-asan": "linux64", | ||
"win64": "windows2012-64" | ||
}; | ||
|
||
// Check the platform name. | ||
var keep = machine == (aliases[platform] || platform); | ||
|
||
// Additional check for LSan. | ||
if (platform == "linux64-asan") { | ||
keep &= coll.asan || coll.lsan; | ||
} | ||
|
||
return keep; | ||
}); | ||
|
||
if (!found) { | ||
return false; | ||
} | ||
|
||
// Finally, filter by build type. | ||
var isDebug = coll.debug || coll.asan || coll.lsan; | ||
return (isDebug && opts.builds.indexOf("d") > -1) || | ||
(!isDebug && opts.builds.indexOf("o") > -1); | ||
}); | ||
} | ||
|
||
module.exports.filterTasks = filterTasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters