summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PRESUBMIT_test_mocks.py3
-rw-r--r--chrome/browser/resources/PRESUBMIT.py6
-rw-r--r--chrome/browser/resources/PRESUBMIT_test.py12
3 files changed, 16 insertions, 5 deletions
diff --git a/PRESUBMIT_test_mocks.py b/PRESUBMIT_test_mocks.py
index 5caa156..03d9232 100644
--- a/PRESUBMIT_test_mocks.py
+++ b/PRESUBMIT_test_mocks.py
@@ -58,6 +58,9 @@ class MockOutputApi(object):
self.items = items
self.long_text = long_text
+ def __repr__(self):
+ return self.message
+
class PresubmitError(PresubmitResult):
def __init__(self, message, items, long_text=''):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
diff --git a/chrome/browser/resources/PRESUBMIT.py b/chrome/browser/resources/PRESUBMIT.py
index 9d6dfaa..502d47a 100644
--- a/chrome/browser/resources/PRESUBMIT.py
+++ b/chrome/browser/resources/PRESUBMIT.py
@@ -79,10 +79,10 @@ def IsBoolean(new_content_lines, metric_name, input_api):
new_content = '\n'.join(new_content_lines)
html_element_re = r'<(.*?)(^|\s+)metric\s*=\s*"%s"(.*?)>' % (metric_name)
- type_re = (r'datatype="boolean"|type="checkbox"|type="radio".*?'
- 'value=("true"|"false")')
+ type_re = (r'datatype\s*=\s*"boolean"|type\s*=\s*"checkbox"|'
+ 'type\s*=\s*"radio".*?value\s*=\s*("true"|"false")')
- match = input_api.re.search(html_element_re, new_content)
+ match = input_api.re.search(html_element_re, new_content, input_api.re.DOTALL)
return (match and
any(input_api.re.search(type_re, match.group(i)) for i in (1, 3)))
diff --git a/chrome/browser/resources/PRESUBMIT_test.py b/chrome/browser/resources/PRESUBMIT_test.py
index d46f3b7..923f2be 100644
--- a/chrome/browser/resources/PRESUBMIT_test.py
+++ b/chrome/browser/resources/PRESUBMIT_test.py
@@ -56,13 +56,21 @@ class HTMLActionAdditionTest(unittest.TestCase):
lines = ['<input id="testinput" pref="testpref"',
'metric="invalidaction" type="checkbox" dialog-pref>']
warnings = self._testChange(lines)
- self.assertEqual(1, len(warnings))
+ self.assertEqual(1, len(warnings), warnings)
def testInValidChange_Radio(self):
lines = ['<input id="testinput" pref="testpref"',
' metric="validaction" type="radio" dialog-pref value="string">']
warnings = self._testChange(lines)
- self.assertEqual(1, len(warnings))
+ self.assertEqual(1, len(warnings), warnings)
+
+ def testValidChange_MultilineType(self):
+ lines = ['<input id="testinput" pref="testpref"\n'
+ ' metric="validaction" type=\n'
+ ' "radio" dialog-pref value=\n'
+ ' "false">']
+ warnings = self._testChange(lines)
+ self.assertEqual([], self._testChange(lines))
def _testChange(self, lines):
mock_input_api = MockInputApi()