Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Unified Diff: PRESUBMIT_test.py

Issue 1413263002: Changed the CheckBaseMacrosInHeaders presubmit to pass over C++ comments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_test.py
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index f5a21ca2ca1170e7c5ca33c9d83db04451a833fb..5aed7eed69dca09badbe94d1d3a217235e08dae1 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())
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698