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
--- a/devtools/server/tests/unit/test_profiler_bufferstatus.js
+++ b/devtools/server/tests/unit/test_profiler_bufferstatus.js
@@ -8,16 +8,17 @@
* Tests if the profiler actor returns its buffer status via getBufferInfo.
*/
const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
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).
Profiler.StopProfiler();
get_chrome_actors((client, form) => {
let actor = form.profilerActor;
check_empty_buffer(client, actor, () => {
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js
@@ -512,37 +512,47 @@ module.exports = {
* @param {RuleContext} scope
* You should pass this from within a rule
* e.g. helpers.getIsHeadFile(context)
*
* @return {String or null}
* 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;
}
}
}
let filepath = this.cleanUpPath(scope.getFilename());
let filename = path.basename(filepath);
if (filename.startsWith("browser_")) {
return "browser";
}
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;
},
getIsWorker(filePath) {
let filename = path.basename(this.cleanUpPath(filePath)).toLowerCase();
return filename.includes("worker");
},