summaryrefslogtreecommitdiffstats
path: root/PRESUBMIT_test.py
diff options
context:
space:
mode:
authordbeam <dbeam@chromium.org>2015-10-16 14:38:03 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-16 21:39:00 +0000
commit3aa3839c53008b3ee094e93f26f25d8306c06cc7 (patch)
tree663bb06f01659e02110b41ebf488c0bb2f556ce0 /PRESUBMIT_test.py
parentfab4db1d9b86a50b2de98164988f326ed96f9a4a (diff)
downloadchromium_src-3aa3839c53008b3ee094e93f26f25d8306c06cc7.zip
chromium_src-3aa3839c53008b3ee094e93f26f25d8306c06cc7.tar.gz
chromium_src-3aa3839c53008b3ee094e93f26f25d8306c06cc7.tar.bz2
PRESUBMIT: Bark about DISALLOW_* macros without #include "base/macros.h"
I'm sick of enforcing this in like every code review. R=cpu@chromium.org,maruel@chromium.org TBR=phajdan.jr@chromium.org BUG=none TEST=PRESUBMIT_test.py Review URL: https://codereview.chromium.org/1411553003 Cr-Commit-Position: refs/heads/master@{#354607}
Diffstat (limited to 'PRESUBMIT_test.py')
-rwxr-xr-xPRESUBMIT_test.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 4d40d8f..f5a21ca 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -413,6 +413,43 @@ class CheckSingletonInHeadersTest(unittest.TestCase):
self.assertEqual(0, len(warnings))
+class CheckBaseMacrosInHeadersTest(unittest.TestCase):
+ def _make_h(self, macro, header):
+ return ("""
+#include "base/%s.h"
+
+class Thing {
+ private:
+ DISALLOW_%s(Thing);
+};
+""" % (macro, header)).splitlines()
+
+ def testBaseMacrosInHeadersBad(self):
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [
+ MockAffectedFile('foo.h', self._make_h('not_macros', 'ASSIGN')),
+ MockAffectedFile('bar.h', self._make_h('not_macros', 'COPY')),
+ MockAffectedFile('baz.h', self._make_h('not_macros', 'COPY_AND_ASSIGN')),
+ MockAffectedFile('qux.h', self._make_h('not_macros', 'EVIL')),
+ ]
+ warnings = PRESUBMIT._CheckBaseMacrosInHeaders(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(1, len(warnings))
+ self.assertEqual(4, len(warnings[0].items))
+
+ def testBaseMacrosInHeadersGood(self):
+ mock_input_api = MockInputApi()
+ mock_input_api.files = [
+ MockAffectedFile('foo.h', self._make_h('macros', 'ASSIGN')),
+ 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')),
+ ]
+ warnings = PRESUBMIT._CheckBaseMacrosInHeaders(mock_input_api,
+ MockOutputApi())
+ self.assertEqual(0, len(warnings))
+
+
class InvalidOSMacroNamesTest(unittest.TestCase):
def testInvalidOSMacroNames(self):
lines = ['#if defined(OS_WINDOWS)',