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

Side by Side Diff: tests/presubmit_unittest.py

Issue 1435333005: Remove unused CheckSvnModifiedDirectories. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « presubmit_canned_checks.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py."""
7 7
8 # pylint: disable=E1101,E1103 8 # pylint: disable=E1101,E1103
9 9
10 import StringIO 10 import StringIO
(...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 'CheckChangeWasUploaded', 1880 'CheckChangeWasUploaded',
1881 'CheckDoNotSubmit', 1881 'CheckDoNotSubmit',
1882 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', 1882 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles',
1883 'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks', 1883 'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks',
1884 'CheckLicense', 1884 'CheckLicense',
1885 'CheckOwners', 1885 'CheckOwners',
1886 'CheckPatchFormatted', 1886 'CheckPatchFormatted',
1887 'CheckGNFormatted', 1887 'CheckGNFormatted',
1888 'CheckRietveldTryJobExecution', 1888 'CheckRietveldTryJobExecution',
1889 'CheckSingletonInHeaders', 1889 'CheckSingletonInHeaders',
1890 'CheckSvnModifiedDirectories',
1891 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', 1890 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty',
1892 'RunPythonUnitTests', 'RunPylint', 1891 'RunPythonUnitTests', 'RunPylint',
1893 'RunUnitTests', 'RunUnitTestsInDirectory', 1892 'RunUnitTests', 'RunUnitTestsInDirectory',
1894 'GetPythonUnitTests', 'GetPylint', 1893 'GetPythonUnitTests', 'GetPylint',
1895 'GetUnitTests', 'GetUnitTestsInDirectory', 'GetUnitTestsRecursively', 1894 'GetUnitTests', 'GetUnitTestsInDirectory', 'GetUnitTestsRecursively',
1896 ] 1895 ]
1897 # If this test fails, you should add the relevant test. 1896 # If this test fails, you should add the relevant test.
1898 self.compareMembers(presubmit_canned_checks, members) 1897 self.compareMembers(presubmit_canned_checks, members)
1899 1898
1900 def DescriptionTest(self, check, description1, description2, error_type, 1899 def DescriptionTest(self, check, description1, description2, error_type,
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 presubmit.OutputApi.PresubmitNotifyResult) 2326 presubmit.OutputApi.PresubmitNotifyResult)
2328 2327
2329 def testCheckLicenseEmptySuccess(self): 2328 def testCheckLicenseEmptySuccess(self):
2330 text = '' 2329 text = ''
2331 license_text = ( 2330 license_text = (
2332 r".*? Copyright \(c\) 2037 Nobody." "\n" 2331 r".*? Copyright \(c\) 2037 Nobody." "\n"
2333 r".*? All Rights Reserved\." "\n" 2332 r".*? All Rights Reserved\." "\n"
2334 ) 2333 )
2335 self._LicenseCheck(text, license_text, True, None, accept_empty_files=True) 2334 self._LicenseCheck(text, license_text, True, None, accept_empty_files=True)
2336 2335
2337 def testCannedCheckSvnAccidentalSubmission(self):
2338 modified_dir_file = 'foo/'
2339 accidental_submssion_file = 'foo/bar.cc'
2340
2341 change = self.mox.CreateMock(presubmit.SvnChange)
2342 change.scm = 'svn'
2343 change.GetModifiedFiles().AndReturn([modified_dir_file])
2344 change.GetAllModifiedFiles().AndReturn([modified_dir_file,
2345 accidental_submssion_file])
2346 input_api = self.MockInputApi(change, True)
2347
2348 affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile)
2349 affected_file.Action().AndReturn('M')
2350 affected_file.IsDirectory().AndReturn(True)
2351 affected_file.AbsoluteLocalPath().AndReturn(accidental_submssion_file)
2352 affected_file.LocalPath().AndReturn(accidental_submssion_file)
2353 input_api.AffectedFiles(file_filter=None).AndReturn([affected_file])
2354
2355 self.mox.ReplayAll()
2356
2357 check = presubmit_canned_checks.CheckSvnModifiedDirectories
2358 results = check(input_api, presubmit.OutputApi, None)
2359 self.assertEquals(len(results), 1)
2360 self.assertEquals(results[0].__class__,
2361 presubmit.OutputApi.PresubmitPromptWarning)
2362
2363 def testCheckSvnForCommonMimeTypes(self): 2336 def testCheckSvnForCommonMimeTypes(self):
2364 self.mox.StubOutWithMock(presubmit_canned_checks, 'CheckSvnProperty') 2337 self.mox.StubOutWithMock(presubmit_canned_checks, 'CheckSvnProperty')
2365 input_api = self.MockInputApi(None, False) 2338 input_api = self.MockInputApi(None, False)
2366 output_api = presubmit.OutputApi(False) 2339 output_api = presubmit.OutputApi(False)
2367 A = lambda x: presubmit.AffectedFile(x, 'M', self.fake_root_dir, None) 2340 A = lambda x: presubmit.AffectedFile(x, 'M', self.fake_root_dir, None)
2368 files = [ 2341 files = [
2369 A('a.pdf'), A('b.bmp'), A('c.gif'), A('d.png'), A('e.jpg'), A('f.jpe'), 2342 A('a.pdf'), A('b.bmp'), A('c.gif'), A('d.png'), A('e.jpg'), A('f.jpe'),
2370 A('random'), A('g.jpeg'), A('h.ico'), 2343 A('random'), A('g.jpeg'), A('h.ico'),
2371 ] 2344 ]
2372 input_api.AffectedFiles(include_deletes=False).AndReturn(files) 2345 input_api.AffectedFiles(include_deletes=False).AndReturn(files)
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
2907 owners_check=False) 2880 owners_check=False)
2908 self.assertEqual(1, len(results)) 2881 self.assertEqual(1, len(results))
2909 self.assertEqual( 2882 self.assertEqual(
2910 'Found line ending with white spaces in:', results[0]._message) 2883 'Found line ending with white spaces in:', results[0]._message)
2911 self.checkstdout('') 2884 self.checkstdout('')
2912 2885
2913 2886
2914 if __name__ == '__main__': 2887 if __name__ == '__main__':
2915 import unittest 2888 import unittest
2916 unittest.main() 2889 unittest.main()
OLDNEW
« no previous file with comments | « presubmit_canned_checks.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698