Bug 1383120 - [eslint-plugin-mozilla] Fix getTestType() helper so mochitests aren't treated as xpcshell tests, r=mossop

This also adds a11y as a test type.

MozReview-Commit-ID: D7y3uALzVQx

--HG--
extra : rebase_source : 6e3c886e28af2c406e86288d99482d59cf6d1852
This commit is contained in:
Andrew Halberstadt 2017-07-21 12:41:27 -04:00
parent e79746fcaa
commit baddb0a4e7
2 changed files with 13 additions and 2 deletions

View File

@ -13,6 +13,7 @@ const INITIAL_WAIT_TIME = 100; // ms
const MAX_WAIT_TIME = 20000; // ms
const MAX_PROFILER_ENTRIES = 10000000;
// eslint-disable-next-line no-unused-vars
function run_test() {
// Ensure the profiler is not running when the test starts (it could
// happen if the MOZ_PROFILER_STARTUP environment variable is set).

View File

@ -517,10 +517,11 @@ module.exports = {
* Test type: xpcshell, browser, chrome, mochitest
*/
getTestType(scope) {
let testTypes = ["browser", "xpcshell", "chrome", "mochitest", "a11y"];
let manifest = this.getTestManifest(scope);
if (manifest) {
let name = path.basename(manifest);
for (let testType of ["browser", "xpcshell", "chrome", "mochitest"]) {
for (let testType of testTypes) {
if (name.startsWith(testType)) {
return testType;
}
@ -535,9 +536,18 @@ module.exports = {
}
if (filename.startsWith("test_")) {
return "xpcshell";
let parent = path.basename(path.dirname(filepath));
for (let testType of testTypes) {
if (parent.startsWith(testType)) {
return testType;
}
}
// It likely is a test, we're just not sure what kind.
return "unknown";
}
// Likely not a test
return null;
},