Commit aded6b9e authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

web_dev_style: fix HTML, JS, and resource checker presubmit tests

BUG=997396

Change-Id: Ia27be3ca7ad06a88ee98b093da988a7a944ba5de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769800
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: default avatarRobbie Iannucci <iannucci@chromium.org>
Auto-Submit: Dan Beam <dbeam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690147}
parent 13cdb8e1
...@@ -11,20 +11,16 @@ import test_util ...@@ -11,20 +11,16 @@ import test_util
import unittest import unittest
_HERE = os_path.dirname(os_path.abspath(__file__)) _HERE = os_path.dirname(os_path.abspath(__file__))
sys_path.append(os_path.join(_HERE, '..', '..', 'build')) sys_path.append(os_path.join(_HERE, '..', '..'))
import find_depot_tools # pylint: disable=W0611 from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
from testing_support.super_mox import SuperMoxTestBase
class HtmlCheckerTest(SuperMoxTestBase): class HtmlCheckerTest(unittest.TestCase):
def setUp(self): def setUp(self):
SuperMoxTestBase.setUp(self) super(HtmlCheckerTest, self).setUp()
input_api = self.mox.CreateMockAnything() self.checker = html_checker.HtmlChecker(MockInputApi(), MockOutputApi())
input_api.re = re
output_api = self.mox.CreateMockAnything()
self.checker = html_checker.HtmlChecker(input_api, output_api)
def ShouldFailCheck(self, line, checker): def ShouldFailCheck(self, line, checker):
"""Checks that the |checker| flags |line| as a style error.""" """Checks that the |checker| flags |line| as a style error."""
......
...@@ -61,10 +61,8 @@ class JSChecker(object): ...@@ -61,10 +61,8 @@ class JSChecker(object):
# Extract paths to be passed to ESLint. # Extract paths to be passed to ESLint.
affected_js_files_paths = [] affected_js_files_paths = []
presubmit_path = self.input_api.PresubmitLocalPath()
for f in affected_js_files: for f in affected_js_files:
affected_js_files_paths.append( affected_js_files_paths.append(f.AbsoluteLocalPath())
os_path.relpath(f.AbsoluteLocalPath(), presubmit_path))
args = ['--color', '--format', format, '--ignore-pattern \'!.eslintrc.js\''] args = ['--color', '--format', format, '--ignore-pattern \'!.eslintrc.js\'']
args += affected_js_files_paths args += affected_js_files_paths
......
...@@ -11,23 +11,19 @@ import test_util ...@@ -11,23 +11,19 @@ import test_util
import unittest import unittest
_HERE = os_path.dirname(os_path.abspath(__file__)) _HERE = os_path.dirname(os_path.abspath(__file__))
sys_path.append(os_path.join(_HERE, '..', '..', 'build')) sys_path.append(os_path.join(_HERE, '..', '..'))
import find_depot_tools # pylint: disable=W0611 from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
from testing_support.super_mox import SuperMoxTestBase
_DECLARATION_METHODS = 'const', 'let', 'var' _DECLARATION_METHODS = 'const', 'let', 'var'
class JsCheckerTest(SuperMoxTestBase): class JsCheckerTest(unittest.TestCase):
def setUp(self): def setUp(self):
SuperMoxTestBase.setUp(self) super(JsCheckerTest, self).setUp()
input_api = self.mox.CreateMockAnything() self.checker = js_checker.JSChecker(MockInputApi(), MockOutputApi())
input_api.re = re
output_api = self.mox.CreateMockAnything()
self.checker = js_checker.JSChecker(input_api, output_api)
def ShouldFailCommentCheck(self, line): def ShouldFailCommentCheck(self, line):
"""Checks that uncommented '<if>' and '<include>' are a style error.""" """Checks that uncommented '<if>' and '<include>' are a style error."""
......
...@@ -11,20 +11,17 @@ import test_util ...@@ -11,20 +11,17 @@ import test_util
import unittest import unittest
_HERE = os_path.dirname(os_path.abspath(__file__)) _HERE = os_path.dirname(os_path.abspath(__file__))
sys_path.append(os_path.join(_HERE, '..', '..', 'build')) sys_path.append(os_path.join(_HERE, '..', '..'))
import find_depot_tools # pylint: disable=W0611 from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
from testing_support.super_mox import SuperMoxTestBase
class ResourceCheckerTest(SuperMoxTestBase): class ResourceCheckerTest(unittest.TestCase):
def setUp(self): def setUp(self):
SuperMoxTestBase.setUp(self) super(ResourceCheckerTest, self).setUp()
input_api = self.mox.CreateMockAnything() self.checker = resource_checker.ResourceChecker(MockInputApi(),
input_api.re = re MockOutputApi())
output_api = self.mox.CreateMockAnything()
self.checker = resource_checker.ResourceChecker(input_api, output_api)
def ShouldPassDeprecatedMojoBindingCheck(self, line): def ShouldPassDeprecatedMojoBindingCheck(self, line):
error = self.checker.DeprecatedMojoBindingsCheck(1, line) error = self.checker.DeprecatedMojoBindingsCheck(1, line)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment