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

Side by Side Diff: tests/presubmit_unittest.py

Issue 399009: Reapply 32057, 32058, 32059, 32062 and fixes problems introduced by these changes. (Closed)
Patch Set: Created 11 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 | « tests/gclient_test.py ('k') | tests/revert_unittest.py » ('j') | 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/python 1 #!/usr/bin/python
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2009 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 import StringIO 8 import StringIO
9 9
10 # Local imports
11 import presubmit_support as presubmit 10 import presubmit_support as presubmit
12 import presubmit_canned_checks 11 # Shortcut.
12 from presubmit_support import presubmit_canned_checks
13 from super_mox import mox, SuperMoxTestBase 13 from super_mox import mox, SuperMoxTestBase
14 14
15 15
16 class PresubmitTestsBase(SuperMoxTestBase): 16 class PresubmitTestsBase(SuperMoxTestBase):
17 """Setups and tear downs the mocks but doesn't test anything as-is.""" 17 """Setups and tear downs the mocks but doesn't test anything as-is."""
18 presubmit_text = """ 18 presubmit_text = """
19 def CheckChangeOnUpload(input_api, output_api): 19 def CheckChangeOnUpload(input_api, output_api):
20 if not input_api.change.NOSUCHKEY: 20 if not input_api.change.NOSUCHKEY:
21 return [output_api.PresubmitError("!!")] 21 return [output_api.PresubmitError("!!")]
22 elif not input_api.change.REALLYNOSUCHKEY: 22 elif not input_api.change.REALLYNOSUCHKEY:
(...skipping 17 matching lines...) Expand all
40 self.fake_root_dir = self.RootDir() 40 self.fake_root_dir = self.RootDir()
41 # Special mocks. 41 # Special mocks.
42 def MockAbsPath(f): 42 def MockAbsPath(f):
43 return f 43 return f
44 def MockChdir(f): 44 def MockChdir(f):
45 return None 45 return None
46 # SuperMoxTestBase already mock these but simplify our life. 46 # SuperMoxTestBase already mock these but simplify our life.
47 presubmit.os.path.abspath = MockAbsPath 47 presubmit.os.path.abspath = MockAbsPath
48 presubmit.os.getcwd = self.RootDir 48 presubmit.os.getcwd = self.RootDir
49 presubmit.os.chdir = MockChdir 49 presubmit.os.chdir = MockChdir
50 self.mox.StubOutWithMock(presubmit.gclient_scm, 'CaptureSVNInfo') 50 self.mox.StubOutWithMock(presubmit.scm.SVN, 'CaptureInfo')
51 self.mox.StubOutWithMock(presubmit.gcl, 'GetSVNFileProperty') 51 self.mox.StubOutWithMock(presubmit.scm.SVN, 'GetFileProperty')
52 # TODO(maruel): Err, small duplication of code here.
52 self.mox.StubOutWithMock(presubmit.gcl, 'ReadFile') 53 self.mox.StubOutWithMock(presubmit.gcl, 'ReadFile')
54 self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileRead')
53 55
54 56
55 class PresubmitUnittest(PresubmitTestsBase): 57 class PresubmitUnittest(PresubmitTestsBase):
56 """General presubmit_support.py tests (excluding InputApi and OutputApi).""" 58 """General presubmit_support.py tests (excluding InputApi and OutputApi)."""
57 def testMembersChanged(self): 59 def testMembersChanged(self):
58 self.mox.ReplayAll() 60 self.mox.ReplayAll()
59 members = [ 61 members = [
60 'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks', 62 'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks',
61 'GetTrySlavesExecuter', 'GitAffectedFile', 'GitChange', 63 'GetTrySlavesExecuter', 'GitAffectedFile', 'GitChange',
62 'InputApi', 'ListRelevantPresubmitFiles', 'Main', 64 'InputApi', 'ListRelevantPresubmitFiles', 'Main',
63 'NotImplementedException', 'OutputApi', 'ParseFiles', 65 'NotImplementedException', 'OutputApi', 'ParseFiles',
64 'PresubmitExecuter', 'PromptYesNo', 'ScanSubDirs', 66 'PresubmitExecuter', 'PromptYesNo', 'ScanSubDirs',
65 'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO', 67 'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO',
66 'exceptions', 'fnmatch', 'gcl', 'gclient_scm', 'glob', 68 'exceptions', 'fnmatch', 'gcl', 'gclient_utils', 'glob',
67 'logging', 'marshal', 'normpath', 'optparse', 'os', 'pickle', 69 'logging', 'marshal', 'normpath', 'optparse', 'os', 'pickle',
68 'presubmit_canned_checks', 'random', 're', 'subprocess', 'sys', 70 'presubmit_canned_checks', 'random', 're', 'scm', 'subprocess', 'sys',
69 'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2', 71 'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2',
70 'warnings', 72 'warnings',
71 ] 73 ]
72 # If this test fails, you should add the relevant test. 74 # If this test fails, you should add the relevant test.
73 self.compareMembers(presubmit, members) 75 self.compareMembers(presubmit, members)
74 76
75 def testListRelevantPresubmitFiles(self): 77 def testListRelevantPresubmitFiles(self):
76 join = presubmit.os.path.join 78 join = presubmit.os.path.join
77 files = [ 79 files = [
78 'blat.cc', 80 'blat.cc',
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 isdir = presubmit.os.path.join(self.fake_root_dir, 'isdir') 135 isdir = presubmit.os.path.join(self.fake_root_dir, 'isdir')
134 presubmit.os.path.exists(blat).AndReturn(True) 136 presubmit.os.path.exists(blat).AndReturn(True)
135 presubmit.os.path.isdir(blat).AndReturn(False) 137 presubmit.os.path.isdir(blat).AndReturn(False)
136 presubmit.os.path.exists(binary).AndReturn(True) 138 presubmit.os.path.exists(binary).AndReturn(True)
137 presubmit.os.path.isdir(binary).AndReturn(False) 139 presubmit.os.path.isdir(binary).AndReturn(False)
138 presubmit.os.path.exists(isdir).AndReturn(True) 140 presubmit.os.path.exists(isdir).AndReturn(True)
139 presubmit.os.path.isdir(isdir).AndReturn(True) 141 presubmit.os.path.isdir(isdir).AndReturn(True)
140 presubmit.os.path.exists(notfound).AndReturn(True) 142 presubmit.os.path.exists(notfound).AndReturn(True)
141 presubmit.os.path.isdir(notfound).AndReturn(False) 143 presubmit.os.path.isdir(notfound).AndReturn(False)
142 presubmit.os.path.exists(flap).AndReturn(False) 144 presubmit.os.path.exists(flap).AndReturn(False)
143 presubmit.gclient_scm.CaptureSVNInfo(flap 145 presubmit.scm.SVN.CaptureInfo(flap
144 ).AndReturn({'Node Kind': 'file'}) 146 ).AndReturn({'Node Kind': 'file'})
145 presubmit.gcl.GetSVNFileProperty(blat, 'svn:mime-type').AndReturn(None) 147 presubmit.scm.SVN.GetFileProperty(blat, 'svn:mime-type').AndReturn(None)
146 presubmit.gcl.GetSVNFileProperty( 148 presubmit.scm.SVN.GetFileProperty(
147 binary, 'svn:mime-type').AndReturn('application/octet-stream') 149 binary, 'svn:mime-type').AndReturn('application/octet-stream')
148 presubmit.gcl.GetSVNFileProperty( 150 presubmit.scm.SVN.GetFileProperty(
149 notfound, 'svn:mime-type').AndReturn('') 151 notfound, 'svn:mime-type').AndReturn('')
150 presubmit.gclient_scm.CaptureSVNInfo(blat).AndReturn( 152 presubmit.scm.SVN.CaptureInfo(blat).AndReturn(
151 {'URL': 'svn:/foo/foo/blat.cc'}) 153 {'URL': 'svn:/foo/foo/blat.cc'})
152 presubmit.gclient_scm.CaptureSVNInfo(binary).AndReturn( 154 presubmit.scm.SVN.CaptureInfo(binary).AndReturn(
153 {'URL': 'svn:/foo/binary.dll'}) 155 {'URL': 'svn:/foo/binary.dll'})
154 presubmit.gclient_scm.CaptureSVNInfo(notfound).AndReturn({}) 156 presubmit.scm.SVN.CaptureInfo(notfound).AndReturn({})
155 presubmit.gclient_scm.CaptureSVNInfo(flap).AndReturn( 157 presubmit.scm.SVN.CaptureInfo(flap).AndReturn(
156 {'URL': 'svn:/foo/boo/flap.h'}) 158 {'URL': 'svn:/foo/boo/flap.h'})
157 presubmit.gcl.ReadFile(blat).AndReturn('boo!\nahh?') 159 presubmit.gclient_utils.FileRead(blat, 'rU').AndReturn('boo!\nahh?')
158 presubmit.gcl.ReadFile(notfound).AndReturn('look!\nthere?') 160 presubmit.gclient_utils.FileRead(notfound, 'rU').AndReturn('look!\nthere?')
159 self.mox.ReplayAll() 161 self.mox.ReplayAll()
160 162
161 change = presubmit.SvnChange('mychange', '\n'.join(description_lines), 163 change = presubmit.SvnChange('mychange', '\n'.join(description_lines),
162 self.fake_root_dir, files, 0, 0) 164 self.fake_root_dir, files, 0, 0)
163 self.failUnless(change.Name() == 'mychange') 165 self.failUnless(change.Name() == 'mychange')
164 self.failUnless(change.DescriptionText() == 166 self.failUnless(change.DescriptionText() ==
165 'Hello there\nthis is a change\nand some more regular text') 167 'Hello there\nthis is a change\nand some more regular text')
166 self.failUnless(change.FullDescriptionText() == 168 self.failUnless(change.FullDescriptionText() ==
167 '\n'.join(description_lines)) 169 '\n'.join(description_lines))
168 170
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 description_lines = ('Hello there', 280 description_lines = ('Hello there',
279 'this is a change', 281 'this is a change',
280 'STORY=http://tracker/123') 282 'STORY=http://tracker/123')
281 files = [ 283 files = [
282 ['A', join('haspresubmit', 'blat.cc')], 284 ['A', join('haspresubmit', 'blat.cc')],
283 ] 285 ]
284 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') 286 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py')
285 root_path = join(self.fake_root_dir, 'PRESUBMIT.py') 287 root_path = join(self.fake_root_dir, 'PRESUBMIT.py')
286 presubmit.os.path.isfile(root_path).AndReturn(True) 288 presubmit.os.path.isfile(root_path).AndReturn(True)
287 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) 289 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True)
288 presubmit.gcl.ReadFile(root_path, 290 presubmit.gclient_utils.FileRead(root_path,
289 'rU').AndReturn(self.presubmit_text) 291 'rU').AndReturn(self.presubmit_text)
290 presubmit.gcl.ReadFile(haspresubmit_path, 292 presubmit.gclient_utils.FileRead(haspresubmit_path,
291 'rU').AndReturn(self.presubmit_text) 293 'rU').AndReturn(self.presubmit_text)
292 presubmit.random.randint(0, 4).AndReturn(1) 294 presubmit.random.randint(0, 4).AndReturn(1)
293 self.mox.ReplayAll() 295 self.mox.ReplayAll()
294 296
295 output = StringIO.StringIO() 297 output = StringIO.StringIO()
296 input = StringIO.StringIO('y\n') 298 input = StringIO.StringIO('y\n')
297 change = presubmit.Change('mychange', '\n'.join(description_lines), 299 change = presubmit.Change('mychange', '\n'.join(description_lines),
298 self.fake_root_dir, files, 0, 0) 300 self.fake_root_dir, files, 0, 0)
299 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input, 301 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input,
300 None, False)) 302 None, False))
301 self.assertEqual(output.getvalue().count('!!'), 2) 303 self.assertEqual(output.getvalue().count('!!'), 2)
302 304
303 def testDoPresubmitChecksPromptsAfterWarnings(self): 305 def testDoPresubmitChecksPromptsAfterWarnings(self):
304 join = presubmit.os.path.join 306 join = presubmit.os.path.join
305 description_lines = ('Hello there', 307 description_lines = ('Hello there',
306 'this is a change', 308 'this is a change',
307 'NOSUCHKEY=http://tracker/123') 309 'NOSUCHKEY=http://tracker/123')
308 files = [ 310 files = [
309 ['A', join('haspresubmit', 'blat.cc')], 311 ['A', join('haspresubmit', 'blat.cc')],
310 ] 312 ]
311 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') 313 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py')
312 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') 314 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py')
313 for i in range(2): 315 for i in range(2):
314 presubmit.os.path.isfile(presubmit_path).AndReturn(True) 316 presubmit.os.path.isfile(presubmit_path).AndReturn(True)
315 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) 317 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True)
316 presubmit.gcl.ReadFile(presubmit_path, 'rU' 318 presubmit.gclient_utils.FileRead(presubmit_path, 'rU'
317 ).AndReturn(self.presubmit_text) 319 ).AndReturn(self.presubmit_text)
318 presubmit.gcl.ReadFile(haspresubmit_path, 'rU' 320 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU'
319 ).AndReturn(self.presubmit_text) 321 ).AndReturn(self.presubmit_text)
320 presubmit.random.randint(0, 4).AndReturn(1) 322 presubmit.random.randint(0, 4).AndReturn(1)
321 presubmit.random.randint(0, 4).AndReturn(1) 323 presubmit.random.randint(0, 4).AndReturn(1)
322 self.mox.ReplayAll() 324 self.mox.ReplayAll()
323 325
324 output = StringIO.StringIO() 326 output = StringIO.StringIO()
325 input = StringIO.StringIO('n\n') # say no to the warning 327 input = StringIO.StringIO('n\n') # say no to the warning
326 change = presubmit.Change('mychange', '\n'.join(description_lines), 328 change = presubmit.Change('mychange', '\n'.join(description_lines),
327 self.fake_root_dir, files, 0, 0) 329 self.fake_root_dir, files, 0, 0)
328 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input, 330 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input,
(...skipping 13 matching lines...) Expand all
342 'NOSUCHKEY=http://tracker/123', 344 'NOSUCHKEY=http://tracker/123',
343 'REALLYNOSUCHKEY=http://tracker/123') 345 'REALLYNOSUCHKEY=http://tracker/123')
344 files = [ 346 files = [
345 ['A', join('haspresubmit', 'blat.cc')], 347 ['A', join('haspresubmit', 'blat.cc')],
346 ] 348 ]
347 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') 349 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py')
348 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 350 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit',
349 'PRESUBMIT.py') 351 'PRESUBMIT.py')
350 presubmit.os.path.isfile(presubmit_path).AndReturn(True) 352 presubmit.os.path.isfile(presubmit_path).AndReturn(True)
351 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) 353 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True)
352 presubmit.gcl.ReadFile(presubmit_path, 'rU').AndReturn(self.presubmit_text) 354 presubmit.gclient_utils.FileRead(presubmit_path, 'rU'
353 presubmit.gcl.ReadFile(haspresubmit_path, 'rU').AndReturn( 355 ).AndReturn(self.presubmit_text)
356 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU').AndReturn(
354 self.presubmit_text) 357 self.presubmit_text)
355 presubmit.random.randint(0, 4).AndReturn(1) 358 presubmit.random.randint(0, 4).AndReturn(1)
356 self.mox.ReplayAll() 359 self.mox.ReplayAll()
357 360
358 output = StringIO.StringIO() 361 output = StringIO.StringIO()
359 input = StringIO.StringIO() # should be unused 362 input = StringIO.StringIO() # should be unused
360 change = presubmit.Change('mychange', '\n'.join(description_lines), 363 change = presubmit.Change('mychange', '\n'.join(description_lines),
361 self.fake_root_dir, files, 0, 0) 364 self.fake_root_dir, files, 0, 0)
362 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input, 365 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input,
363 None, False)) 366 None, False))
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 str(result))) 498 str(result)))
496 499
497 def testDoGetTrySlaves(self): 500 def testDoGetTrySlaves(self):
498 join = presubmit.os.path.join 501 join = presubmit.os.path.join
499 filename = 'foo.cc' 502 filename = 'foo.cc'
500 filename_linux = join('linux_only', 'penguin.cc') 503 filename_linux = join('linux_only', 'penguin.cc')
501 root_presubmit = join(self.fake_root_dir, 'PRESUBMIT.py') 504 root_presubmit = join(self.fake_root_dir, 'PRESUBMIT.py')
502 linux_presubmit = join(self.fake_root_dir, 'linux_only', 'PRESUBMIT.py') 505 linux_presubmit = join(self.fake_root_dir, 'linux_only', 'PRESUBMIT.py')
503 506
504 presubmit.os.path.isfile(root_presubmit).AndReturn(True) 507 presubmit.os.path.isfile(root_presubmit).AndReturn(True)
505 presubmit.gcl.ReadFile(root_presubmit, 'rU').AndReturn( 508 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn(
506 self.presubmit_tryslave % '["win"]') 509 self.presubmit_tryslave % '["win"]')
507 510
508 presubmit.os.path.isfile(root_presubmit).AndReturn(True) 511 presubmit.os.path.isfile(root_presubmit).AndReturn(True)
509 presubmit.os.path.isfile(linux_presubmit).AndReturn(True) 512 presubmit.os.path.isfile(linux_presubmit).AndReturn(True)
510 presubmit.gcl.ReadFile(root_presubmit, 'rU').AndReturn( 513 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn(
511 self.presubmit_tryslave % '["win"]') 514 self.presubmit_tryslave % '["win"]')
512 presubmit.gcl.ReadFile(linux_presubmit, 'rU').AndReturn( 515 presubmit.gclient_utils.FileRead(linux_presubmit, 'rU').AndReturn(
513 self.presubmit_tryslave % '["linux"]') 516 self.presubmit_tryslave % '["linux"]')
514 self.mox.ReplayAll() 517 self.mox.ReplayAll()
515 518
516 output = StringIO.StringIO() 519 output = StringIO.StringIO()
517 self.assertEqual(['win'], 520 self.assertEqual(['win'],
518 presubmit.DoGetTrySlaves([filename], self.fake_root_dir, 521 presubmit.DoGetTrySlaves([filename], self.fake_root_dir,
519 None, False, output)) 522 None, False, output))
520 output = StringIO.StringIO() 523 output = StringIO.StringIO()
521 self.assertEqual(['win', 'linux'], 524 self.assertEqual(['win', 'linux'],
522 presubmit.DoGetTrySlaves([filename, filename_linux], 525 presubmit.DoGetTrySlaves([filename, filename_linux],
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 'basename', 'cPickle', 'cStringIO', 'canned_checks', 'change', 'environ', 561 'basename', 'cPickle', 'cStringIO', 'canned_checks', 'change', 'environ',
559 'is_committing', 'marshal', 'os_path', 'pickle', 'platform', 562 'is_committing', 'marshal', 'os_path', 'pickle', 'platform',
560 'python_executable', 563 'python_executable',
561 're', 'subprocess', 'tempfile', 'traceback', 'unittest', 'urllib2', 564 're', 'subprocess', 'tempfile', 'traceback', 'unittest', 'urllib2',
562 'version', 565 'version',
563 ] 566 ]
564 # If this test fails, you should add the relevant test. 567 # If this test fails, you should add the relevant test.
565 self.compareMembers(presubmit.InputApi(None, './.', False), members) 568 self.compareMembers(presubmit.InputApi(None, './.', False), members)
566 569
567 def testDepotToLocalPath(self): 570 def testDepotToLocalPath(self):
568 presubmit.gclient_scm.CaptureSVNInfo('svn://foo/smurf').AndReturn( 571 presubmit.scm.SVN.CaptureInfo('svn://foo/smurf').AndReturn(
569 {'Path': 'prout'}) 572 {'Path': 'prout'})
570 presubmit.gclient_scm.CaptureSVNInfo('svn:/foo/notfound/burp').AndReturn({}) 573 presubmit.scm.SVN.CaptureInfo('svn:/foo/notfound/burp').AndReturn({})
571 self.mox.ReplayAll() 574 self.mox.ReplayAll()
572 575
573 path = presubmit.InputApi(None, './p', False).DepotToLocalPath( 576 path = presubmit.InputApi(None, './p', False).DepotToLocalPath(
574 'svn://foo/smurf') 577 'svn://foo/smurf')
575 self.failUnless(path == 'prout') 578 self.failUnless(path == 'prout')
576 path = presubmit.InputApi(None, './p', False).DepotToLocalPath( 579 path = presubmit.InputApi(None, './p', False).DepotToLocalPath(
577 'svn:/foo/notfound/burp') 580 'svn:/foo/notfound/burp')
578 self.failUnless(path == None) 581 self.failUnless(path == None)
579 582
580 def testLocalToDepotPath(self): 583 def testLocalToDepotPath(self):
581 presubmit.gclient_scm.CaptureSVNInfo('smurf').AndReturn({'URL': 584 presubmit.scm.SVN.CaptureInfo('smurf').AndReturn({'URL':
582 'svn://foo'}) 585 'svn://foo'})
583 presubmit.gclient_scm.CaptureSVNInfo('notfound-food').AndReturn({}) 586 presubmit.scm.SVN.CaptureInfo('notfound-food').AndReturn({})
584 self.mox.ReplayAll() 587 self.mox.ReplayAll()
585 588
586 path = presubmit.InputApi(None, './p', False).LocalToDepotPath('smurf') 589 path = presubmit.InputApi(None, './p', False).LocalToDepotPath('smurf')
587 self.assertEqual(path, 'svn://foo') 590 self.assertEqual(path, 'svn://foo')
588 path = presubmit.InputApi(None, './p', False).LocalToDepotPath( 591 path = presubmit.InputApi(None, './p', False).LocalToDepotPath(
589 'notfound-food') 592 'notfound-food')
590 self.failUnless(path == None) 593 self.failUnless(path == None)
591 594
592 def testInputApiConstruction(self): 595 def testInputApiConstruction(self):
593 self.mox.ReplayAll() 596 self.mox.ReplayAll()
(...skipping 30 matching lines...) Expand all
624 beingdeleted = presubmit.normpath(join(self.fake_root_dir, files[6][1])) 627 beingdeleted = presubmit.normpath(join(self.fake_root_dir, files[6][1]))
625 notfound = presubmit.normpath(join(self.fake_root_dir, files[7][1])) 628 notfound = presubmit.normpath(join(self.fake_root_dir, files[7][1]))
626 flap = presubmit.normpath(join(self.fake_root_dir, files[8][1])) 629 flap = presubmit.normpath(join(self.fake_root_dir, files[8][1]))
627 for i in (blat, readme, binary, weird, another, third_party): 630 for i in (blat, readme, binary, weird, another, third_party):
628 presubmit.os.path.exists(i).AndReturn(True) 631 presubmit.os.path.exists(i).AndReturn(True)
629 presubmit.os.path.isdir(i).AndReturn(False) 632 presubmit.os.path.isdir(i).AndReturn(False)
630 presubmit.os.path.exists(beingdeleted).AndReturn(False) 633 presubmit.os.path.exists(beingdeleted).AndReturn(False)
631 presubmit.os.path.exists(notfound).AndReturn(False) 634 presubmit.os.path.exists(notfound).AndReturn(False)
632 presubmit.os.path.exists(flap).AndReturn(True) 635 presubmit.os.path.exists(flap).AndReturn(True)
633 presubmit.os.path.isdir(flap).AndReturn(False) 636 presubmit.os.path.isdir(flap).AndReturn(False)
634 presubmit.gclient_scm.CaptureSVNInfo(beingdeleted).AndReturn({}) 637 presubmit.scm.SVN.CaptureInfo(beingdeleted).AndReturn({})
635 presubmit.gclient_scm.CaptureSVNInfo(notfound).AndReturn({}) 638 presubmit.scm.SVN.CaptureInfo(notfound).AndReturn({})
636 presubmit.gcl.GetSVNFileProperty(blat, 'svn:mime-type').AndReturn(None) 639 presubmit.scm.SVN.GetFileProperty(blat, 'svn:mime-type').AndReturn(None)
637 presubmit.gcl.GetSVNFileProperty(readme, 'svn:mime-type').AndReturn(None) 640 presubmit.scm.SVN.GetFileProperty(readme, 'svn:mime-type').AndReturn(None)
638 presubmit.gcl.GetSVNFileProperty(binary, 'svn:mime-type').AndReturn( 641 presubmit.scm.SVN.GetFileProperty(binary, 'svn:mime-type').AndReturn(
639 'application/octet-stream') 642 'application/octet-stream')
640 presubmit.gcl.GetSVNFileProperty(weird, 'svn:mime-type').AndReturn(None) 643 presubmit.scm.SVN.GetFileProperty(weird, 'svn:mime-type').AndReturn(None)
641 presubmit.gcl.GetSVNFileProperty(another, 'svn:mime-type').AndReturn(None) 644 presubmit.scm.SVN.GetFileProperty(another, 'svn:mime-type').AndReturn(None)
642 presubmit.gcl.GetSVNFileProperty(third_party, 'svn:mime-type' 645 presubmit.scm.SVN.GetFileProperty(third_party, 'svn:mime-type'
643 ).AndReturn(None) 646 ).AndReturn(None)
644 presubmit.gcl.ReadFile(blat).AndReturn('whatever\ncookie') 647 presubmit.gclient_utils.FileRead(blat, 'rU'
645 presubmit.gcl.ReadFile(another).AndReturn('whatever\ncookie2') 648 ).AndReturn('whatever\ncookie')
649 presubmit.gclient_utils.FileRead(another, 'rU'
650 ).AndReturn('whatever\ncookie2')
646 self.mox.ReplayAll() 651 self.mox.ReplayAll()
647 652
648 change = presubmit.SvnChange('mychange', '\n'.join(description_lines), 653 change = presubmit.SvnChange('mychange', '\n'.join(description_lines),
649 self.fake_root_dir, files, 0, 0) 654 self.fake_root_dir, files, 0, 0)
650 input_api = presubmit.InputApi(change, 655 input_api = presubmit.InputApi(change,
651 join(self.fake_root_dir, 'foo', 656 join(self.fake_root_dir, 'foo',
652 'PRESUBMIT.py'), 657 'PRESUBMIT.py'),
653 False) 658 False)
654 # Doesn't filter much 659 # Doesn't filter much
655 got_files = input_api.AffectedFiles() 660 got_files = input_api.AffectedFiles()
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 self.assertEquals(len(results), len(item[1])) 752 self.assertEquals(len(results), len(item[1]))
748 753
749 def testCustomFilter(self): 754 def testCustomFilter(self):
750 def FilterSourceFile(affected_file): 755 def FilterSourceFile(affected_file):
751 return 'a' in affected_file.LocalPath() 756 return 'a' in affected_file.LocalPath()
752 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee')] 757 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee')]
753 for (action, item) in files: 758 for (action, item) in files:
754 item = presubmit.os.path.join(self.fake_root_dir, item) 759 item = presubmit.os.path.join(self.fake_root_dir, item)
755 presubmit.os.path.exists(item).AndReturn(True) 760 presubmit.os.path.exists(item).AndReturn(True)
756 presubmit.os.path.isdir(item).AndReturn(False) 761 presubmit.os.path.isdir(item).AndReturn(False)
757 presubmit.gcl.GetSVNFileProperty(item, 'svn:mime-type').AndReturn(None) 762 presubmit.scm.SVN.GetFileProperty(item, 'svn:mime-type').AndReturn(None)
758 self.mox.ReplayAll() 763 self.mox.ReplayAll()
759 764
760 change = presubmit.SvnChange('mychange', '', self.fake_root_dir, files, 0, 765 change = presubmit.SvnChange('mychange', '', self.fake_root_dir, files, 0,
761 0) 766 0)
762 input_api = presubmit.InputApi(change, 767 input_api = presubmit.InputApi(change,
763 presubmit.os.path.join(self.fake_root_dir, 768 presubmit.os.path.join(self.fake_root_dir,
764 'PRESUBMIT.py'), 769 'PRESUBMIT.py'),
765 False) 770 False)
766 got_files = input_api.AffectedSourceFiles(FilterSourceFile) 771 got_files = input_api.AffectedSourceFiles(FilterSourceFile)
767 self.assertEquals(len(got_files), 2) 772 self.assertEquals(len(got_files), 2)
768 self.assertEquals(got_files[0].LocalPath(), 'eeaee') 773 self.assertEquals(got_files[0].LocalPath(), 'eeaee')
769 self.assertEquals(got_files[1].LocalPath(), 'eeabee') 774 self.assertEquals(got_files[1].LocalPath(), 'eeabee')
770 775
771 def testLambdaFilter(self): 776 def testLambdaFilter(self):
772 white_list = presubmit.InputApi.DEFAULT_BLACK_LIST + (r".*?a.*?",) 777 white_list = presubmit.InputApi.DEFAULT_BLACK_LIST + (r".*?a.*?",)
773 black_list = [r".*?b.*?"] 778 black_list = [r".*?b.*?"]
774 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee'), ('M', 'eecaee')] 779 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee'), ('M', 'eecaee')]
775 for (action, item) in files: 780 for (action, item) in files:
776 item = presubmit.os.path.join(self.fake_root_dir, item) 781 item = presubmit.os.path.join(self.fake_root_dir, item)
777 presubmit.os.path.exists(item).AndReturn(True) 782 presubmit.os.path.exists(item).AndReturn(True)
778 presubmit.os.path.isdir(item).AndReturn(False) 783 presubmit.os.path.isdir(item).AndReturn(False)
779 presubmit.gcl.GetSVNFileProperty(item, 'svn:mime-type').AndReturn(None) 784 presubmit.scm.SVN.GetFileProperty(item, 'svn:mime-type').AndReturn(None)
780 self.mox.ReplayAll() 785 self.mox.ReplayAll()
781 786
782 change = presubmit.SvnChange('mychange', '', self.fake_root_dir, files, 0, 787 change = presubmit.SvnChange('mychange', '', self.fake_root_dir, files, 0,
783 0) 788 0)
784 input_api = presubmit.InputApi(change, './PRESUBMIT.py', False) 789 input_api = presubmit.InputApi(change, './PRESUBMIT.py', False)
785 # Sample usage of overiding the default white and black lists. 790 # Sample usage of overiding the default white and black lists.
786 got_files = input_api.AffectedSourceFiles( 791 got_files = input_api.AffectedSourceFiles(
787 lambda x: input_api.FilterSourceFile(x, white_list, black_list)) 792 lambda x: input_api.FilterSourceFile(x, white_list, black_list))
788 self.assertEquals(len(got_files), 2) 793 self.assertEquals(len(got_files), 2)
789 self.assertEquals(got_files[0].LocalPath(), 'eeaee') 794 self.assertEquals(got_files[0].LocalPath(), 'eeaee')
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 self.mox.ReplayAll() 850 self.mox.ReplayAll()
846 851
847 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')], 852 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')],
848 0, 0) 853 0, 0)
849 input_api = presubmit.InputApi( 854 input_api = presubmit.InputApi(
850 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False) 855 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False)
851 self.assertRaises(IOError, input_api.ReadFile, 'boo', 'x') 856 self.assertRaises(IOError, input_api.ReadFile, 'boo', 'x')
852 857
853 def testReadFileStringAccepted(self): 858 def testReadFileStringAccepted(self):
854 path = presubmit.os.path.join(self.fake_root_dir, 'AA/boo') 859 path = presubmit.os.path.join(self.fake_root_dir, 'AA/boo')
855 presubmit.gcl.ReadFile(path, 'x').AndReturn(None) 860 presubmit.gclient_utils.FileRead(path, 'x').AndReturn(None)
856 self.mox.ReplayAll() 861 self.mox.ReplayAll()
857 862
858 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')], 863 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')],
859 0, 0) 864 0, 0)
860 input_api = presubmit.InputApi( 865 input_api = presubmit.InputApi(
861 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False) 866 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False)
862 input_api.ReadFile(path, 'x') 867 input_api.ReadFile(path, 'x')
863 868
864 def testReadFileAffectedFileDenied(self): 869 def testReadFileAffectedFileDenied(self):
865 file = presubmit.AffectedFile('boo', 'M', 'Unrelated') 870 file = presubmit.AffectedFile('boo', 'M', 'Unrelated')
866 self.mox.ReplayAll() 871 self.mox.ReplayAll()
867 872
868 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')], 873 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')],
869 0, 0) 874 0, 0)
870 input_api = presubmit.InputApi( 875 input_api = presubmit.InputApi(
871 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False) 876 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False)
872 self.assertRaises(IOError, input_api.ReadFile, file, 'x') 877 self.assertRaises(IOError, input_api.ReadFile, file, 'x')
873 878
874 def testReadFileAffectedFileAccepted(self): 879 def testReadFileAffectedFileAccepted(self):
875 file = presubmit.AffectedFile('AA/boo', 'M', self.fake_root_dir) 880 file = presubmit.AffectedFile('AA/boo', 'M', self.fake_root_dir)
876 presubmit.gcl.ReadFile(file.AbsoluteLocalPath(), 'x').AndReturn(None) 881 presubmit.gclient_utils.FileRead(file.AbsoluteLocalPath(), 'x'
882 ).AndReturn(None)
877 self.mox.ReplayAll() 883 self.mox.ReplayAll()
878 884
879 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')], 885 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')],
880 0, 0) 886 0, 0)
881 input_api = presubmit.InputApi( 887 input_api = presubmit.InputApi(
882 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False) 888 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False)
883 input_api.ReadFile(file, 'x') 889 input_api.ReadFile(file, 'x')
884 890
885 891
886 class OuputApiUnittest(PresubmitTestsBase): 892 class OuputApiUnittest(PresubmitTestsBase):
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 'NewContents', 'OldContents', 'OldFileTempPath', 'Property', 'ServerPath', 954 'NewContents', 'OldContents', 'OldFileTempPath', 'Property', 'ServerPath',
949 ] 955 ]
950 # If this test fails, you should add the relevant test. 956 # If this test fails, you should add the relevant test.
951 self.compareMembers(presubmit.AffectedFile('a', 'b'), members) 957 self.compareMembers(presubmit.AffectedFile('a', 'b'), members)
952 self.compareMembers(presubmit.SvnAffectedFile('a', 'b'), members) 958 self.compareMembers(presubmit.SvnAffectedFile('a', 'b'), members)
953 959
954 def testAffectedFile(self): 960 def testAffectedFile(self):
955 path = presubmit.os.path.join('foo', 'blat.cc') 961 path = presubmit.os.path.join('foo', 'blat.cc')
956 presubmit.os.path.exists(path).AndReturn(True) 962 presubmit.os.path.exists(path).AndReturn(True)
957 presubmit.os.path.isdir(path).AndReturn(False) 963 presubmit.os.path.isdir(path).AndReturn(False)
958 presubmit.gcl.ReadFile(path).AndReturn('whatever\ncookie') 964 presubmit.gclient_utils.FileRead(path, 'rU').AndReturn('whatever\ncookie')
959 presubmit.gclient_scm.CaptureSVNInfo(path).AndReturn( 965 presubmit.scm.SVN.CaptureInfo(path).AndReturn(
960 {'URL': 'svn:/foo/foo/blat.cc'}) 966 {'URL': 'svn:/foo/foo/blat.cc'})
961 self.mox.ReplayAll() 967 self.mox.ReplayAll()
962 af = presubmit.SvnAffectedFile('foo/blat.cc', 'M') 968 af = presubmit.SvnAffectedFile('foo/blat.cc', 'M')
963 self.failUnless(af.ServerPath() == 'svn:/foo/foo/blat.cc') 969 self.failUnless(af.ServerPath() == 'svn:/foo/foo/blat.cc')
964 self.failUnless(af.LocalPath() == presubmit.normpath('foo/blat.cc')) 970 self.failUnless(af.LocalPath() == presubmit.normpath('foo/blat.cc'))
965 self.failUnless(af.Action() == 'M') 971 self.failUnless(af.Action() == 'M')
966 self.assertEquals(af.NewContents(), ['whatever', 'cookie']) 972 self.assertEquals(af.NewContents(), ['whatever', 'cookie'])
967 af = presubmit.AffectedFile('notfound.cc', 'A') 973 af = presubmit.AffectedFile('notfound.cc', 'A')
968 self.failUnless(af.ServerPath() == '') 974 self.failUnless(af.ServerPath() == '')
969 975
970 def testProperty(self): 976 def testProperty(self):
971 presubmit.gcl.GetSVNFileProperty('foo.cc', 'svn:secret-property' 977 presubmit.scm.SVN.GetFileProperty('foo.cc', 'svn:secret-property'
972 ).AndReturn('secret-property-value') 978 ).AndReturn('secret-property-value')
973 self.mox.ReplayAll() 979 self.mox.ReplayAll()
974 affected_file = presubmit.SvnAffectedFile('foo.cc', 'A') 980 affected_file = presubmit.SvnAffectedFile('foo.cc', 'A')
975 # Verify cache coherency. 981 # Verify cache coherency.
976 self.failUnless(affected_file.Property('svn:secret-property') == 982 self.failUnless(affected_file.Property('svn:secret-property') ==
977 'secret-property-value') 983 'secret-property-value')
978 self.failUnless(affected_file.Property('svn:secret-property') == 984 self.failUnless(affected_file.Property('svn:secret-property') ==
979 'secret-property-value') 985 'secret-property-value')
980 986
981 def testIsDirectoryNotExists(self): 987 def testIsDirectoryNotExists(self):
982 presubmit.os.path.exists('foo.cc').AndReturn(False) 988 presubmit.os.path.exists('foo.cc').AndReturn(False)
983 presubmit.gclient_scm.CaptureSVNInfo('foo.cc').AndReturn({}) 989 presubmit.scm.SVN.CaptureInfo('foo.cc').AndReturn({})
984 self.mox.ReplayAll() 990 self.mox.ReplayAll()
985 affected_file = presubmit.SvnAffectedFile('foo.cc', 'A') 991 affected_file = presubmit.SvnAffectedFile('foo.cc', 'A')
986 # Verify cache coherency. 992 # Verify cache coherency.
987 self.failIf(affected_file.IsDirectory()) 993 self.failIf(affected_file.IsDirectory())
988 self.failIf(affected_file.IsDirectory()) 994 self.failIf(affected_file.IsDirectory())
989 995
990 def testIsDirectory(self): 996 def testIsDirectory(self):
991 presubmit.os.path.exists('foo.cc').AndReturn(True) 997 presubmit.os.path.exists('foo.cc').AndReturn(True)
992 presubmit.os.path.isdir('foo.cc').AndReturn(True) 998 presubmit.os.path.isdir('foo.cc').AndReturn(True)
993 self.mox.ReplayAll() 999 self.mox.ReplayAll()
994 affected_file = presubmit.SvnAffectedFile('foo.cc', 'A') 1000 affected_file = presubmit.SvnAffectedFile('foo.cc', 'A')
995 # Verify cache coherency. 1001 # Verify cache coherency.
996 self.failUnless(affected_file.IsDirectory()) 1002 self.failUnless(affected_file.IsDirectory())
997 self.failUnless(affected_file.IsDirectory()) 1003 self.failUnless(affected_file.IsDirectory())
998 1004
999 def testIsTextFile(self): 1005 def testIsTextFile(self):
1000 list = [presubmit.SvnAffectedFile('foo/blat.txt', 'M'), 1006 list = [presubmit.SvnAffectedFile('foo/blat.txt', 'M'),
1001 presubmit.SvnAffectedFile('foo/binary.blob', 'M'), 1007 presubmit.SvnAffectedFile('foo/binary.blob', 'M'),
1002 presubmit.SvnAffectedFile('blat/flop.txt', 'D')] 1008 presubmit.SvnAffectedFile('blat/flop.txt', 'D')]
1003 blat = presubmit.os.path.join('foo', 'blat.txt') 1009 blat = presubmit.os.path.join('foo', 'blat.txt')
1004 blob = presubmit.os.path.join('foo', 'binary.blob') 1010 blob = presubmit.os.path.join('foo', 'binary.blob')
1005 presubmit.os.path.exists(blat).AndReturn(True) 1011 presubmit.os.path.exists(blat).AndReturn(True)
1006 presubmit.os.path.isdir(blat).AndReturn(False) 1012 presubmit.os.path.isdir(blat).AndReturn(False)
1007 presubmit.os.path.exists(blob).AndReturn(True) 1013 presubmit.os.path.exists(blob).AndReturn(True)
1008 presubmit.os.path.isdir(blob).AndReturn(False) 1014 presubmit.os.path.isdir(blob).AndReturn(False)
1009 presubmit.gcl.GetSVNFileProperty(blat, 'svn:mime-type').AndReturn(None) 1015 presubmit.scm.SVN.GetFileProperty(blat, 'svn:mime-type').AndReturn(None)
1010 presubmit.gcl.GetSVNFileProperty(blob, 'svn:mime-type' 1016 presubmit.scm.SVN.GetFileProperty(blob, 'svn:mime-type'
1011 ).AndReturn('application/octet-stream') 1017 ).AndReturn('application/octet-stream')
1012 self.mox.ReplayAll() 1018 self.mox.ReplayAll()
1013 1019
1014 output = filter(lambda x: x.IsTextFile(), list) 1020 output = filter(lambda x: x.IsTextFile(), list)
1015 self.failUnless(len(output) == 1) 1021 self.failUnless(len(output) == 1)
1016 self.failUnless(list[0] == output[0]) 1022 self.failUnless(list[0] == output[0])
1017 1023
1018 1024
1019 class GclChangeUnittest(PresubmitTestsBase): 1025 class GclChangeUnittest(PresubmitTestsBase):
1020 def testMembersChanged(self): 1026 def testMembersChanged(self):
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 change1 = presubmit.SvnChange('mychange', '', self.fake_root_dir, [], 0, 0) 1150 change1 = presubmit.SvnChange('mychange', '', self.fake_root_dir, [], 0, 0)
1145 input_api1 = self.MockInputApi(change1, committing) 1151 input_api1 = self.MockInputApi(change1, committing)
1146 files1 = [ 1152 files1 = [
1147 presubmit.SvnAffectedFile('foo/bar.cc', 'A'), 1153 presubmit.SvnAffectedFile('foo/bar.cc', 'A'),
1148 presubmit.SvnAffectedFile('foo.cc', 'M'), 1154 presubmit.SvnAffectedFile('foo.cc', 'M'),
1149 ] 1155 ]
1150 if use_source_file: 1156 if use_source_file:
1151 input_api1.AffectedSourceFiles(None).AndReturn(files1) 1157 input_api1.AffectedSourceFiles(None).AndReturn(files1)
1152 else: 1158 else:
1153 input_api1.AffectedFiles(include_deleted=False).AndReturn(files1) 1159 input_api1.AffectedFiles(include_deleted=False).AndReturn(files1)
1154 presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo/bar.cc'), 1160 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo/bar.cc'),
1155 property).AndReturn(value1) 1161 property).AndReturn(value1)
1156 presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo.cc'), 1162 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo.cc'),
1157 property).AndReturn(value1) 1163 property).AndReturn(value1)
1158 change2 = presubmit.SvnChange('mychange', '', self.fake_root_dir, [], 0, 0) 1164 change2 = presubmit.SvnChange('mychange', '', self.fake_root_dir, [], 0, 0)
1159 input_api2 = self.MockInputApi(change2, committing) 1165 input_api2 = self.MockInputApi(change2, committing)
1160 files2 = [ 1166 files2 = [
1161 presubmit.SvnAffectedFile('foo/bar.cc', 'A'), 1167 presubmit.SvnAffectedFile('foo/bar.cc', 'A'),
1162 presubmit.SvnAffectedFile('foo.cc', 'M'), 1168 presubmit.SvnAffectedFile('foo.cc', 'M'),
1163 ] 1169 ]
1164 if use_source_file: 1170 if use_source_file:
1165 input_api2.AffectedSourceFiles(None).AndReturn(files2) 1171 input_api2.AffectedSourceFiles(None).AndReturn(files2)
1166 else: 1172 else:
1167 input_api2.AffectedFiles(include_deleted=False).AndReturn(files2) 1173 input_api2.AffectedFiles(include_deleted=False).AndReturn(files2)
1168 1174
1169 presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo/bar.cc'), 1175 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo/bar.cc'),
1170 property).AndReturn(value2) 1176 property).AndReturn(value2)
1171 presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo.cc'), 1177 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo.cc'),
1172 property).AndReturn(value2) 1178 property).AndReturn(value2)
1173 self.mox.ReplayAll() 1179 self.mox.ReplayAll()
1174 1180
1175 results1 = check(input_api1, presubmit.OutputApi, None) 1181 results1 = check(input_api1, presubmit.OutputApi, None)
1176 self.assertEquals(results1, []) 1182 self.assertEquals(results1, [])
1177 results2 = check(input_api2, presubmit.OutputApi, None) 1183 results2 = check(input_api2, presubmit.OutputApi, None)
1178 self.assertEquals(len(results2), 1) 1184 self.assertEquals(len(results2), 1)
1179 self.assertEquals(results2[0].__class__, error_type) 1185 self.assertEquals(results2[0].__class__, error_type)
1180 1186
1181 def testCannedCheckChangeHasBugField(self): 1187 def testCannedCheckChangeHasBugField(self):
1182 self.DescriptionTest(presubmit_canned_checks.CheckChangeHasBugField, 1188 self.DescriptionTest(presubmit_canned_checks.CheckChangeHasBugField,
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 self.mox.ReplayAll() 1460 self.mox.ReplayAll()
1455 1461
1456 results = presubmit_canned_checks.RunPythonUnitTests( 1462 results = presubmit_canned_checks.RunPythonUnitTests(
1457 input_api, presubmit.OutputApi, ['test_module']) 1463 input_api, presubmit.OutputApi, ['test_module'])
1458 self.assertEquals(len(results), 0) 1464 self.assertEquals(len(results), 0)
1459 1465
1460 1466
1461 if __name__ == '__main__': 1467 if __name__ == '__main__':
1462 import unittest 1468 import unittest
1463 unittest.main() 1469 unittest.main()
OLDNEW
« no previous file with comments | « tests/gclient_test.py ('k') | tests/revert_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698