From 5a2af6d9d1f745197c094bd639647d9d3307297e Mon Sep 17 00:00:00 2001 From: "dbeam@chromium.org" Date: Thu, 8 Oct 2015 17:52:29 +0000 Subject: [PATCH] Add long line exception for GEN('#include') in JS browser tests. It's basically like C++'s #include but in JS. Why write 1 language when you can write 2?! R=maruel@chromium.org BUG=540977 Review URL: https://codereview.chromium.org/1394563003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297065 0039d316-1c4b-4281-b951-d872f2087c98 --- presubmit_canned_checks.py | 5 ++++- tests/presubmit_unittest.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 5ed86568ff..c04f84cf01 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -342,15 +342,18 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None): CPP_EXCEPTIONS = ('#define', '#endif', '#if', '#include', '#pragma') JAVA_FILE_EXTS = ('java',) JAVA_EXCEPTIONS = ('import ', 'package ') + JS_FILE_EXTS = ('js',) + JS_EXCEPTIONS = ("GEN('#include",) OBJC_FILE_EXTS = ('h', 'm', 'mm') OBJC_EXCEPTIONS = ('#define', '#endif', '#if', '#import', '#include', '#pragma') - PY_FILE_EXTS = ('py') + PY_FILE_EXTS = ('py',) PY_EXCEPTIONS = ('import', 'from') LANGUAGE_EXCEPTIONS = [ (CPP_FILE_EXTS, CPP_EXCEPTIONS), (JAVA_FILE_EXTS, JAVA_EXCEPTIONS), + (JS_FILE_EXTS, JS_EXCEPTIONS), (OBJC_FILE_EXTS, OBJC_EXCEPTIONS), (PY_FILE_EXTS, PY_EXCEPTIONS), ] diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 87832d46c3..d72b6b1e88 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -2179,6 +2179,12 @@ class CannedChecksUnittest(PresubmitTestsBase): 'importSomething ' + 'A ' * 50, 'foo.java', presubmit.OutputApi.PresubmitPromptWarning) + def testCannedCheckJSLongLines(self): + check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 10) + self.ContentTest(check, 'GEN(\'#include "c/b/ui/webui/fixture.h"\');', + 'foo.js', "// GEN('something');", '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',