diff options
author | oysteine <oysteine@chromium.org> | 2015-10-22 13:55:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-22 20:55:58 +0000 |
commit | c430ad4e9110a195902c7b8e886026e8d8353327 (patch) | |
tree | ae6e3201bbe5e5a279d49b063052ddba97ade6ba /PRESUBMIT_test.py | |
parent | ea9850a4ac10792b291f2821c4338aa708c1519d (diff) | |
download | chromium_src-c430ad4e9110a195902c7b8e886026e8d8353327.zip chromium_src-c430ad4e9110a195902c7b8e886026e8d8353327.tar.gz chromium_src-c430ad4e9110a195902c7b8e886026e8d8353327.tar.bz2 |
Changed the CheckBaseMacrosInHeaders presubmit to pass over C++ comments
R=dbeam@chromium.org,maruel@chromium.org
BUG=545272
Review URL: https://codereview.chromium.org/1413263002
Cr-Commit-Position: refs/heads/master@{#355639}
Diffstat (limited to 'PRESUBMIT_test.py')
-rwxr-xr-x | PRESUBMIT_test.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py index f5a21ca..5aed7ee 100755 --- a/PRESUBMIT_test.py +++ b/PRESUBMIT_test.py @@ -392,15 +392,18 @@ class CheckSingletonInHeadersTest(unittest.TestCase): 'base::Singleton<Type, Traits, DifferentiatingType>::'] diff_foo_h = ['// base::Singleton<Foo> in comment.', 'friend class base::Singleton<Foo>'] + diff_foo2_h = [' //Foo* bar = base::Singleton<Foo>::get();'] diff_bad_h = ['Foo* foo = base::Singleton<Foo>::get();'] mock_input_api = MockInputApi() mock_input_api.files = [MockAffectedFile('base/memory/singleton.h', diff_singleton_h), MockAffectedFile('foo.h', diff_foo_h), + MockAffectedFile('foo2.h', diff_foo2_h), MockAffectedFile('bad.h', diff_bad_h)] warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api, MockOutputApi()) self.assertEqual(1, len(warnings)) + self.assertEqual(2, len(warnings[0].items)) self.assertEqual('error', warnings[0].type) self.assertTrue('Found base::Singleton<T>' in warnings[0].message) @@ -414,15 +417,15 @@ class CheckSingletonInHeadersTest(unittest.TestCase): class CheckBaseMacrosInHeadersTest(unittest.TestCase): - def _make_h(self, macro, header): + def _make_h(self, macro, header, line_prefix=''): return (""" #include "base/%s.h" class Thing { private: - DISALLOW_%s(Thing); +%sDISALLOW_%s(Thing); }; -""" % (macro, header)).splitlines() +""" % (macro, line_prefix, header)).splitlines() def testBaseMacrosInHeadersBad(self): mock_input_api = MockInputApi() @@ -444,6 +447,8 @@ class Thing { MockAffectedFile('bar.h', self._make_h('macros', 'COPY')), MockAffectedFile('baz.h', self._make_h('macros', 'COPY_AND_ASSIGN')), MockAffectedFile('qux.h', self._make_h('macros', 'EVIL')), + MockAffectedFile('foz.h', self._make_h('not_macros', 'ASSIGN', '//')), + MockAffectedFile('foz.h', self._make_h('not_macros', 'ASSIGN', ' //')), ] warnings = PRESUBMIT._CheckBaseMacrosInHeaders(mock_input_api, MockOutputApi()) |