From c3617f3fdd9d7bf8019a83097bd3ce2869f1a37c Mon Sep 17 00:00:00 2001 From: "glider@chromium.org" Date: Thu, 19 Feb 2015 16:33:33 +0000 Subject: [PATCH] Remove the Singleton presubmit check from presubmit_canned_checks.py This check is specific to Chromium codebase, there's no point in having it in depot_tools. BUG=None R=maruel@chromium.org Review URL: https://codereview.chromium.org/924863002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294124 0039d316-1c4b-4281-b951-d872f2087c98 --- presubmit_canned_checks.py | 28 +++++---------------------- tests/presubmit_unittest.py | 38 ------------------------------------- 2 files changed, 5 insertions(+), 61 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index bd628fb36..4e55d5087 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -971,26 +971,11 @@ def _CheckConstNSObject(input_api, output_api, source_file_filter): def CheckSingletonInHeaders(input_api, output_api, source_file_filter=None): - """Checks to make sure no header files have |Singleton<|.""" - pattern = input_api.re.compile(r'(? in the following header files.\n' + - 'Please move them to an appropriate source file so that the ' + - 'template gets instantiated in a single compilation unit.', - files) ] - return [] + """Deprecated, must be removed.""" + return [ + output_api.PresubmitNotifyResult( + 'CheckSingletonInHeaders is deprecated, please remove it.') + ] def PanProjectChecks(input_api, output_api, @@ -1078,9 +1063,6 @@ def PanProjectChecks(input_api, output_api, snapshot("checking nsobjects") results.extend(_CheckConstNSObject( input_api, output_api, source_file_filter=sources)) - snapshot("checking singletons") - results.extend(CheckSingletonInHeaders( - input_api, output_api, source_file_filter=sources)) # The following checks are only done on commit, since the commit bot will # auto-fix most of these. diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index e46457e0a..4be5daffe 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -2087,41 +2087,6 @@ class CannedChecksUnittest(PresubmitTestsBase): 'Foo', None, 'Foo ', None, presubmit.OutputApi.PresubmitPromptWarning) - def testCheckSingletonInHeaders(self): - change1 = presubmit.Change( - 'foo1', 'foo1\n', self.fake_root_dir, None, 0, 0, None) - input_api1 = self.MockInputApi(change1, False) - affected_file1 = self.mox.CreateMock(presubmit.SvnAffectedFile) - affected_file2 = self.mox.CreateMock(presubmit.SvnAffectedFile) - input_api1.AffectedSourceFiles(None).AndReturn( - [affected_file1, affected_file2]) - affected_file1.LocalPath().AndReturn('foo.h') - input_api1.ReadFile(affected_file1).AndReturn( - '// Comment mentioning Singleton.\n' + - 'friend class Singleton;') - for _ in range(4): - affected_file2.LocalPath().AndReturn('foo.cc') - - change2 = presubmit.Change( - 'foo2', 'foo2\n', self.fake_root_dir, None, 0, 0, None) - input_api2 = self.MockInputApi(change2, False) - - affected_file3 = self.mox.CreateMock(presubmit.SvnAffectedFile) - input_api2.AffectedSourceFiles(None).AndReturn([affected_file3]) - affected_file3.LocalPath().AndReturn('foo.h') - input_api2.ReadFile(affected_file3).AndReturn( - 'Foo* foo = Singleton::get();') - - self.mox.ReplayAll() - - results1 = presubmit_canned_checks.CheckSingletonInHeaders( - input_api1, presubmit.OutputApi) - self.assertEquals(results1, []) - results2 = presubmit_canned_checks.CheckSingletonInHeaders( - input_api2, presubmit.OutputApi) - self.assertEquals(len(results2), 1) - self.assertEquals(results2[0].__class__, presubmit.OutputApi.PresubmitError) - def testCheckChangeHasOnlyOneEol(self): self.ReadFileTest(presubmit_canned_checks.CheckChangeHasOnlyOneEol, "Hey!\nHo!\n", "Hey!\nHo!\n\n", @@ -2889,9 +2854,6 @@ class CannedChecksUnittest(PresubmitTestsBase): affected_file.LocalPath().AndReturn('hello.py') input_api.AffectedSourceFiles(mox.IgnoreArg()).AndReturn([affected_file]) input_api.ReadFile(affected_file).AndReturn('Hey!\nHo!\nHey!\nHo!\n\n') - input_api.AffectedSourceFiles(mox.IgnoreArg()).AndReturn([affected_file]) - for _ in range(4): - affected_file.LocalPath().AndReturn('hello.py') self.mox.ReplayAll() results = presubmit_canned_checks.PanProjectChecks(