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

Exclude ES imports from long lines check

Bug: 1028829
Change-Id: Iafc40952e402884639543436281e93942c0257a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1959813
Auto-Submit: Dan Beam <dbeam@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
parent 989da695
......@@ -416,7 +416,7 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None):
JAVA_FILE_EXTS = ('java',)
JAVA_EXCEPTIONS = ('import ', 'package ')
JS_FILE_EXTS = ('js',)
JS_EXCEPTIONS = ("GEN('#include",)
JS_EXCEPTIONS = ("GEN('#include", 'import ')
OBJC_FILE_EXTS = ('h', 'm', 'mm')
OBJC_EXCEPTIONS = ('#define', '#endif', '#if', '#import', '#include',
'#pragma')
......
......@@ -1511,6 +1511,13 @@ class CannedChecksUnittest(PresubmitTestsBase):
'bfoo',
'cfoo',
'dfoo']
# It falls back to ChangedContents when there is a failure. This is an
# optimization since NewContents() is much faster to execute than
# ChangedContents().
affected_file1.ChangedContents.return_value = [
(42, content1),
(43, 'hfoo'),
(23, 'ifoo')]
change2 = presubmit.Change(
'foo2', 'foo2\n', self.fake_root_dir, None, 0, 0, None)
......@@ -1525,14 +1532,10 @@ class CannedChecksUnittest(PresubmitTestsBase):
'efoo',
'ffoo',
'gfoo']
# It falls back to ChangedContents when there is a failure. This is an
# optimization since NewContents() is much faster to execute than
# ChangedContents().
affected_file2.ChangedContents.return_value = [
(42, content2),
(43, 'hfoo'),
(23, 'ifoo')]
affected_file2.LocalPath.return_value = 'foo.cc'
results1 = check(input_api1, presubmit.OutputApi, None)
......@@ -1843,6 +1846,12 @@ the current line as well!
'foo.js', "// GEN('something');", 'foo.js',
presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckJSLongImports(self):
check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 10)
self.ContentTest(check, "import {Name, otherName} from './dir/file.js';",
'foo.js', "// We should import something long, eh?",
'foo.js', presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckObjCExceptionLongLines(self):
check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80)
self.ContentTest(check, '#import ' + 'A ' * 150, 'foo.mm',
......
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