Bug 1383120 - [eslint-plugin-mozilla] Fix getTestType() helper so mochitests aren't treated as xpcshell tests, r=mossop
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 21 Jul 2017 12:41:27 -0400
changeset 419818 7d00186874cf02330bcc45e994324070e97706a9
parent 419817 a38aa0ec8f16b5fb67617b5d188d851bae56b133
child 419819 4653ae9b9f1717ad1a05c75eb9c0d2a73e9ed644
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1383120
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
devtools/server/tests/unit/test_profiler_bufferstatus.js
tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js
--- 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");
   },