Bug 1506559 - Enable ESLint for memory/replace/dmd/test/. r=njn
authorMark Banner <standard8@mozilla.com>
Tue, 13 Nov 2018 09:07:38 +0000
changeset 505206 92a23275c087fb829e45e766b23afeed7ea0b816
parent 505205 0eacaa309ef7410dd45d61930ada74f71911e230
child 505207 05353b73a6ac0b364461093a90f0a02a3a1b32cb
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1506559
milestone65.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 1506559 - Enable ESLint for memory/replace/dmd/test/. r=njn Differential Revision: https://phabricator.services.mozilla.com/D11619
.eslintignore
memory/replace/dmd/test/.eslintrc.js
memory/replace/dmd/test/test_dmd.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -21,17 +21,16 @@ extensions/cookie/**
 extensions/spellcheck/**
 extensions/universalchardet/**
 gfx/layers/**
 gfx/tests/browser/**
 gfx/tests/chrome/**
 gfx/tests/mochitest/**
 image/**
 layout/**
-memory/replace/dmd/test/**
 modules/**
 netwerk/cookie/test/browser/**
 netwerk/test/browser/**
 netwerk/test/mochitests/**
 netwerk/test/unit*/**
 parser/**
 tools/update-packaging/**
 uriloader/exthandler/**
new file mode 100644
--- /dev/null
+++ b/memory/replace/dmd/test/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+  "extends": [
+    "plugin:mozilla/xpcshell-test"
+  ]
+};
--- a/memory/replace/dmd/test/test_dmd.js
+++ b/memory/replace/dmd/test/test_dmd.js
@@ -1,19 +1,18 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-*/
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 "use strict";
 
-var {classes: Cc, interfaces: Ci, utils: Cu} = Components
-
 ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 // The xpcshell test harness sets PYTHON so we can read it here.
 var gEnv = Cc["@mozilla.org/process/environment;1"]
              .getService(Ci.nsIEnvironment);
 var gPythonName = gEnv.get("PYTHON");
 
 // If we're testing locally, the executable file is in "CurProcD". Otherwise,
 // it is in another location that we have to find.
@@ -25,18 +24,17 @@ function getExecutable(aFilename) {
       file = file.parent;
     }
     file.append("bin");
     file.append(aFilename);
   }
   return file;
 }
 
-var gIsWindows = Cc["@mozilla.org/xre/app-info;1"]
-                 .getService(Ci.nsIXULRuntime).OS === "WINNT";
+var gIsWindows = Services.appinfo.OS === "WINNT";
 var gDmdTestFile = getExecutable("SmokeDMD" + (gIsWindows ? ".exe" : ""));
 
 var gDmdScriptFile = getExecutable("dmd.py");
 
 var gScanTestFile = FileUtils.getFile("CurWorkD", ["scan-test.py"]);
 
 function readFile(aFile) {
   let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
@@ -50,17 +48,17 @@ function readFile(aFile) {
   let str = {};
   let read = 0;
   do {
     // Read as much as we can and put it in str.value.
     read = cstream.readString(0xffffffff, str);
     data += str.value;
   } while (read != 0);
 
-  cstream.close();                // this closes fstream
+  cstream.close(); // this closes fstream
   return data.replace(/\r/g, ""); // normalize line endings
 }
 
 function runProcess(aExeFile, aArgs) {
   let process = Cc["@mozilla.org/process/util;1"]
                   .createInstance(Ci.nsIProcess);
   process.init(aExeFile);
   process.run(/* blocking = */true, aArgs, aArgs.length);
@@ -73,17 +71,17 @@ function test(aPrefix, aArgs) {
   let expectedFile = FileUtils.getFile("CurWorkD", [aPrefix + "-expected.txt"]);
   let actualFile   = FileUtils.getFile("CurWorkD", [aPrefix + "-actual.txt"]);
 
   // Run dmd.py on the JSON file, producing |actualFile|.
 
   let args = [
     gDmdScriptFile.path,
     "--filter-stacks-for-testing",
-    "-o", actualFile.path
+    "-o", actualFile.path,
   ].concat(aArgs);
 
   runProcess(new FileUtils.File(gPythonName), args);
 
   // Compare |expectedFile| with |actualFile|. We produce nice diffs with
   // /usr/bin/diff on systems that have it (Mac and Linux). Otherwise (Windows)
   // we do a string compare of the file contents and then print them both if
   // they don't match.
@@ -131,17 +129,17 @@ function run_test() {
   // These tests do complete end-to-end testing of DMD, i.e. both the C++ code
   // that generates the JSON output, and the script that post-processes that
   // output.
   //
   // Run these synchronously, because test() updates the complete*.json files
   // in-place (to fix stacks) when it runs dmd.py, and that's not safe to do
   // asynchronously.
 
-  gEnv.set('DMD', '1');
+  gEnv.set("DMD", "1");
 
   runProcess(gDmdTestFile, []);
 
   function test2(aTestName, aMode) {
     let name = "complete-" + aTestName + "-" + aMode;
     jsonFile = FileUtils.getFile("CurWorkD", [name + ".json"]);
     test(name, [jsonFile.path]);
     jsonFile.remove(true);
@@ -160,18 +158,17 @@ function run_test() {
   test2("full2", "cumulative");
 
   test2("partial", "live");
 
   // Heap scan testing.
   jsonFile = FileUtils.getFile("CurWorkD", ["basic-scan.json"]);
   ok(scanTest(jsonFile.path), "Basic scan test");
 
-  let is64Bit = Cc["@mozilla.org/xre/app-info;1"]
-                  .getService(Ci.nsIXULRuntime).is64Bit;
+  let is64Bit = Services.appinfo.is64Bit;
   let basicScanFileName = "basic-scan-" + (is64Bit ? "64" : "32");
   test(basicScanFileName, ["--clamp-contents", jsonFile.path]);
   ok(scanTest(jsonFile.path, ["--clamp-contents"]), "Scan with address clamping");
 
   // Run the generic test a second time to ensure that the first time produced
   // valid JSON output. "--clamp-contents" is passed in so we don't have to have
   // more variants of the files.
   test(basicScanFileName, ["--clamp-contents", jsonFile.path]);
@@ -182,17 +179,17 @@ function run_test() {
   // explaining how they work, but JSON doesn't allow comments, so I've put
   // explanations here.
 
   // This just tests that stack traces of various lengths are truncated
   // appropriately. The number of records in the output is different for each
   // of the tested values.
   jsonFile = FileUtils.getFile("CurWorkD", ["script-max-frames.json"]);
   test("script-max-frames-8",
-       [jsonFile.path]);  // --max-frames=8 is the default
+       [jsonFile.path]); // --max-frames=8 is the default
   test("script-max-frames-3",
        ["--max-frames=3", "--no-fix-stacks", jsonFile.path]);
   test("script-max-frames-1",
        ["--max-frames=1", jsonFile.path]);
 
   // This file has three records that are shown in a different order for each
   // of the different sort values. It also tests the handling of gzipped JSON
   // files.