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

Side by Side Diff: tests/presubmit_unittest.py

Issue 5695007: Enhance RunPylint to use white_list and black_list arguments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: address review comment Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « tests/gclient_utils_test.py ('k') | tests/scm_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) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 is too confused.
9 # pylint: disable=E1101,E1103,W0212,W0403
10
8 import StringIO 11 import StringIO
9 12
10 # Fixes include path. 13 # Fixes include path.
11 from super_mox import mox, SuperMoxTestBase 14 from super_mox import mox, SuperMoxTestBase
12 15
13 import presubmit_support as presubmit 16 import presubmit_support as presubmit
14 # Shortcut. 17 # Shortcut.
15 presubmit_canned_checks = presubmit.presubmit_canned_checks 18 presubmit_canned_checks = presubmit.presubmit_canned_checks
16 19
17 20
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 ' STORY =http://foo/ \t', 162 ' STORY =http://foo/ \t',
160 'and some more regular text \t') 163 'and some more regular text \t')
161 files = [ 164 files = [
162 ['A', 'foo/blat.cc'], 165 ['A', 'foo/blat.cc'],
163 ['M', 'binary.dll'], # a binary file 166 ['M', 'binary.dll'], # a binary file
164 ['A', 'isdir'], # a directory 167 ['A', 'isdir'], # a directory
165 ['?', 'flop/notfound.txt'], # not found in SVN, still exists locally 168 ['?', 'flop/notfound.txt'], # not found in SVN, still exists locally
166 ['D', 'boo/flap.h'], 169 ['D', 'boo/flap.h'],
167 ] 170 ]
168 blat = presubmit.os.path.join(self.fake_root_dir, 'foo', 'blat.cc') 171 blat = presubmit.os.path.join(self.fake_root_dir, 'foo', 'blat.cc')
169 notfound = presubmit.os.path.join(self.fake_root_dir, 'flop', 'notfound.txt' ) 172 notfound = presubmit.os.path.join(
173 self.fake_root_dir, 'flop', 'notfound.txt')
170 flap = presubmit.os.path.join(self.fake_root_dir, 'boo', 'flap.h') 174 flap = presubmit.os.path.join(self.fake_root_dir, 'boo', 'flap.h')
171 binary = presubmit.os.path.join(self.fake_root_dir, 'binary.dll') 175 binary = presubmit.os.path.join(self.fake_root_dir, 'binary.dll')
172 isdir = presubmit.os.path.join(self.fake_root_dir, 'isdir') 176 isdir = presubmit.os.path.join(self.fake_root_dir, 'isdir')
173 presubmit.os.path.exists(blat).AndReturn(True) 177 presubmit.os.path.exists(blat).AndReturn(True)
174 presubmit.os.path.isdir(blat).AndReturn(False) 178 presubmit.os.path.isdir(blat).AndReturn(False)
175 presubmit.os.path.exists(binary).AndReturn(True) 179 presubmit.os.path.exists(binary).AndReturn(True)
176 presubmit.os.path.isdir(binary).AndReturn(False) 180 presubmit.os.path.isdir(binary).AndReturn(False)
177 presubmit.os.path.exists(isdir).AndReturn(True) 181 presubmit.os.path.exists(isdir).AndReturn(True)
178 presubmit.os.path.isdir(isdir).AndReturn(True) 182 presubmit.os.path.isdir(isdir).AndReturn(True)
179 presubmit.os.path.exists(notfound).AndReturn(True) 183 presubmit.os.path.exists(notfound).AndReturn(True)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 presubmit.os.path.isfile(root_path).AndReturn(True) 332 presubmit.os.path.isfile(root_path).AndReturn(True)
329 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) 333 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True)
330 presubmit.gclient_utils.FileRead(root_path, 334 presubmit.gclient_utils.FileRead(root_path,
331 'rU').AndReturn(self.presubmit_text) 335 'rU').AndReturn(self.presubmit_text)
332 presubmit.gclient_utils.FileRead(haspresubmit_path, 336 presubmit.gclient_utils.FileRead(haspresubmit_path,
333 'rU').AndReturn(self.presubmit_text) 337 'rU').AndReturn(self.presubmit_text)
334 presubmit.random.randint(0, 4).AndReturn(1) 338 presubmit.random.randint(0, 4).AndReturn(1)
335 self.mox.ReplayAll() 339 self.mox.ReplayAll()
336 340
337 output = StringIO.StringIO() 341 output = StringIO.StringIO()
338 input = StringIO.StringIO('y\n') 342 input_buf = StringIO.StringIO('y\n')
339 change = presubmit.Change('mychange', '\n'.join(description_lines), 343 change = presubmit.Change('mychange', '\n'.join(description_lines),
340 self.fake_root_dir, files, 0, 0) 344 self.fake_root_dir, files, 0, 0)
341 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input, 345 self.failIf(presubmit.DoPresubmitChecks(
342 None, False)) 346 change, False, True, output, input_buf, None, False))
343 self.assertEqual(output.getvalue().count('!!'), 2) 347 self.assertEqual(output.getvalue().count('!!'), 2)
344 self.checkstdout('Running presubmit hooks...\n') 348 self.checkstdout('Running presubmit hooks...\n')
345 349
346 def testDoPresubmitChecksPromptsAfterWarnings(self): 350 def testDoPresubmitChecksPromptsAfterWarnings(self):
347 join = presubmit.os.path.join 351 join = presubmit.os.path.join
348 description_lines = ('Hello there', 352 description_lines = ('Hello there',
349 'this is a change', 353 'this is a change',
350 'NOSUCHKEY=http://tracker/123') 354 'NOSUCHKEY=http://tracker/123')
351 files = [ 355 files = [
352 ['A', join('haspresubmit', 'blat.cc')], 356 ['A', join('haspresubmit', 'blat.cc')],
353 ] 357 ]
354 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') 358 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py')
355 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') 359 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py')
356 inherit_path = presubmit.os.path.join(self.fake_root_dir, 360 inherit_path = presubmit.os.path.join(self.fake_root_dir,
357 self._INHERIT_SETTINGS) 361 self._INHERIT_SETTINGS)
358 for i in range(2): 362 for _ in range(2):
359 presubmit.os.path.isfile(inherit_path).AndReturn(False) 363 presubmit.os.path.isfile(inherit_path).AndReturn(False)
360 presubmit.os.path.isfile(presubmit_path).AndReturn(True) 364 presubmit.os.path.isfile(presubmit_path).AndReturn(True)
361 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) 365 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True)
362 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' 366 presubmit.gclient_utils.FileRead(presubmit_path, 'rU'
363 ).AndReturn(self.presubmit_text) 367 ).AndReturn(self.presubmit_text)
364 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU' 368 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU'
365 ).AndReturn(self.presubmit_text) 369 ).AndReturn(self.presubmit_text)
366 presubmit.random.randint(0, 4).AndReturn(1) 370 presubmit.random.randint(0, 4).AndReturn(1)
367 presubmit.random.randint(0, 4).AndReturn(1) 371 presubmit.random.randint(0, 4).AndReturn(1)
368 self.mox.ReplayAll() 372 self.mox.ReplayAll()
369 373
370 output = StringIO.StringIO() 374 output = StringIO.StringIO()
371 input = StringIO.StringIO('n\n') # say no to the warning 375 input_buf = StringIO.StringIO('n\n') # say no to the warning
372 change = presubmit.Change('mychange', '\n'.join(description_lines), 376 change = presubmit.Change('mychange', '\n'.join(description_lines),
373 self.fake_root_dir, files, 0, 0) 377 self.fake_root_dir, files, 0, 0)
374 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input, 378 self.failIf(presubmit.DoPresubmitChecks(
375 None, True)) 379 change, False, True, output, input_buf, None, True))
376 self.assertEqual(output.getvalue().count('??'), 2) 380 self.assertEqual(output.getvalue().count('??'), 2)
377 381
378 output = StringIO.StringIO() 382 output = StringIO.StringIO()
379 input = StringIO.StringIO('y\n') # say yes to the warning 383 input_buf = StringIO.StringIO('y\n') # say yes to the warning
380 self.failUnless(presubmit.DoPresubmitChecks(change, False, True, output, 384 self.failUnless(presubmit.DoPresubmitChecks(
381 input, None, True)) 385 change, False, True, output, input_buf, None, True))
382 self.assertEquals(output.getvalue().count('??'), 2) 386 self.assertEquals(output.getvalue().count('??'), 2)
383 self.checkstdout('Running presubmit hooks...\nRunning presubmit hooks...\n') 387 self.checkstdout('Running presubmit hooks...\nRunning presubmit hooks...\n')
384 388
385 def testDoPresubmitChecksNoWarningPromptIfErrors(self): 389 def testDoPresubmitChecksNoWarningPromptIfErrors(self):
386 join = presubmit.os.path.join 390 join = presubmit.os.path.join
387 description_lines = ('Hello there', 391 description_lines = ('Hello there',
388 'this is a change', 392 'this is a change',
389 'NOSUCHKEY=http://tracker/123', 393 'NOSUCHKEY=http://tracker/123',
390 'REALLYNOSUCHKEY=http://tracker/123') 394 'REALLYNOSUCHKEY=http://tracker/123')
391 files = [ 395 files = [
392 ['A', join('haspresubmit', 'blat.cc')], 396 ['A', join('haspresubmit', 'blat.cc')],
393 ] 397 ]
394 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') 398 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py')
395 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 399 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit',
396 'PRESUBMIT.py') 400 'PRESUBMIT.py')
397 inherit_path = presubmit.os.path.join(self.fake_root_dir, 401 inherit_path = presubmit.os.path.join(self.fake_root_dir,
398 self._INHERIT_SETTINGS) 402 self._INHERIT_SETTINGS)
399 presubmit.os.path.isfile(inherit_path).AndReturn(False) 403 presubmit.os.path.isfile(inherit_path).AndReturn(False)
400 presubmit.os.path.isfile(presubmit_path).AndReturn(True) 404 presubmit.os.path.isfile(presubmit_path).AndReturn(True)
401 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) 405 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True)
402 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' 406 presubmit.gclient_utils.FileRead(presubmit_path, 'rU'
403 ).AndReturn(self.presubmit_text) 407 ).AndReturn(self.presubmit_text)
404 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU').AndReturn( 408 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU').AndReturn(
405 self.presubmit_text) 409 self.presubmit_text)
406 presubmit.random.randint(0, 4).AndReturn(1) 410 presubmit.random.randint(0, 4).AndReturn(1)
407 self.mox.ReplayAll() 411 self.mox.ReplayAll()
408 412
409 output = StringIO.StringIO() 413 output = StringIO.StringIO()
410 input = StringIO.StringIO() # should be unused 414 input_buf = StringIO.StringIO() # should be unused
411 change = presubmit.Change('mychange', '\n'.join(description_lines), 415 change = presubmit.Change('mychange', '\n'.join(description_lines),
412 self.fake_root_dir, files, 0, 0) 416 self.fake_root_dir, files, 0, 0)
413 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input, 417 self.failIf(presubmit.DoPresubmitChecks(
414 None, False)) 418 change, False, True, output, input_buf, None, False))
415 self.assertEqual(output.getvalue().count('??'), 2) 419 self.assertEqual(output.getvalue().count('??'), 2)
416 self.assertEqual(output.getvalue().count('XX!!XX'), 2) 420 self.assertEqual(output.getvalue().count('XX!!XX'), 2)
417 self.assertEqual(output.getvalue().count('(y/N)'), 0) 421 self.assertEqual(output.getvalue().count('(y/N)'), 0)
418 self.checkstdout('Running presubmit hooks...\n') 422 self.checkstdout('Running presubmit hooks...\n')
419 423
420 def testDoDefaultPresubmitChecksAndFeedback(self): 424 def testDoDefaultPresubmitChecksAndFeedback(self):
421 join = presubmit.os.path.join 425 join = presubmit.os.path.join
422 description_lines = ('Hello there', 426 description_lines = ('Hello there',
423 'this is a change', 427 'this is a change',
424 'STORY=http://tracker/123') 428 'STORY=http://tracker/123')
(...skipping 11 matching lines...) Expand all
436 presubmit.os.path.isfile(inherit_path).AndReturn(False) 440 presubmit.os.path.isfile(inherit_path).AndReturn(False)
437 presubmit.os.path.isfile(join(self.fake_root_dir, 'PRESUBMIT.py') 441 presubmit.os.path.isfile(join(self.fake_root_dir, 'PRESUBMIT.py')
438 ).AndReturn(False) 442 ).AndReturn(False)
439 presubmit.os.path.isfile(join(self.fake_root_dir, 443 presubmit.os.path.isfile(join(self.fake_root_dir,
440 'haspresubmit', 444 'haspresubmit',
441 'PRESUBMIT.py')).AndReturn(False) 445 'PRESUBMIT.py')).AndReturn(False)
442 presubmit.random.randint(0, 4).AndReturn(0) 446 presubmit.random.randint(0, 4).AndReturn(0)
443 self.mox.ReplayAll() 447 self.mox.ReplayAll()
444 448
445 output = StringIO.StringIO() 449 output = StringIO.StringIO()
446 input = StringIO.StringIO('y\n') 450 input_buf = StringIO.StringIO('y\n')
447 # Always fail. 451 # Always fail.
448 change = presubmit.Change('mychange', '\n'.join(description_lines), 452 change = presubmit.Change('mychange', '\n'.join(description_lines),
449 self.fake_root_dir, files, 0, 0) 453 self.fake_root_dir, files, 0, 0)
450 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input, 454 self.failIf(presubmit.DoPresubmitChecks(
451 DEFAULT_SCRIPT, False)) 455 change, False, True, output, input_buf, DEFAULT_SCRIPT, False))
452 text = ('Warning, no presubmit.py found.\n' 456 text = ('Warning, no presubmit.py found.\n'
453 'Running default presubmit script.\n' 457 'Running default presubmit script.\n'
454 '** Presubmit ERRORS **\n!!\n\n' 458 '** Presubmit ERRORS **\n!!\n\n'
455 'Was the presubmit check useful? Please send feedback & hate mail ' 459 'Was the presubmit check useful? Please send feedback & hate mail '
456 'to maruel@chromium.org!\n') 460 'to maruel@chromium.org!\n')
457 self.assertEquals(output.getvalue(), text) 461 self.assertEquals(output.getvalue(), text)
458 self.checkstdout('Running presubmit hooks...\n') 462 self.checkstdout('Running presubmit hooks...\n')
459 463
460 def testDirectoryHandling(self): 464 def testDirectoryHandling(self):
461 files = [ 465 files = [
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 def CheckChangeOnCommit(input_api, output_api): 513 def CheckChangeOnCommit(input_api, output_api):
510 raise Exception("Test error") 514 raise Exception("Test error")
511 """ 515 """
512 presubmit.random.randint(0, 4).AndReturn(1) 516 presubmit.random.randint(0, 4).AndReturn(1)
513 inherit_path = presubmit.os.path.join(self.fake_root_dir, 517 inherit_path = presubmit.os.path.join(self.fake_root_dir,
514 self._INHERIT_SETTINGS) 518 self._INHERIT_SETTINGS)
515 presubmit.os.path.isfile(inherit_path).AndReturn(False) 519 presubmit.os.path.isfile(inherit_path).AndReturn(False)
516 self.mox.ReplayAll() 520 self.mox.ReplayAll()
517 521
518 output = StringIO.StringIO() 522 output = StringIO.StringIO()
519 input = StringIO.StringIO('y\n') 523 input_buf = StringIO.StringIO('y\n')
520 change = presubmit.Change( 524 change = presubmit.Change(
521 'foo', "Blah Blah\n\nSTORY=http://tracker.com/42\nBUG=boo\n", 525 'foo', "Blah Blah\n\nSTORY=http://tracker.com/42\nBUG=boo\n",
522 self.fake_root_dir, None, 0, 0) 526 self.fake_root_dir, None, 0, 0)
523 self.failUnless(presubmit.DoPresubmitChecks(change, False, True, output, 527 self.failUnless(presubmit.DoPresubmitChecks(
524 input, DEFAULT_SCRIPT, False)) 528 change, False, True, output, input_buf, DEFAULT_SCRIPT, False))
525 self.assertEquals(output.getvalue(), 529 self.assertEquals(output.getvalue(),
526 ('Warning, no presubmit.py found.\n' 530 ('Warning, no presubmit.py found.\n'
527 'Running default presubmit script.\n' 531 'Running default presubmit script.\n'
528 '** Presubmit Messages **\n' 532 '** Presubmit Messages **\n'
529 'http://tracker.com/42\n\n')) 533 'http://tracker.com/42\n\n'))
530 self.checkstdout('Running presubmit hooks...\n') 534 self.checkstdout('Running presubmit hooks...\n')
531 535
532 def testGetTrySlavesExecuter(self): 536 def testGetTrySlavesExecuter(self):
533 self.mox.ReplayAll() 537 self.mox.ReplayAll()
534 538
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 presubmit.normpath(item[1][i])) 814 presubmit.normpath(item[1][i]))
811 # Same number of expected results. 815 # Same number of expected results.
812 self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/') 816 self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/')
813 for f in results]), 817 for f in results]),
814 sorted(item[1])) 818 sorted(item[1]))
815 819
816 def testCustomFilter(self): 820 def testCustomFilter(self):
817 def FilterSourceFile(affected_file): 821 def FilterSourceFile(affected_file):
818 return 'a' in affected_file.LocalPath() 822 return 'a' in affected_file.LocalPath()
819 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee')] 823 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee')]
820 for (action, item) in files: 824 for _, item in files:
821 item = presubmit.os.path.join(self.fake_root_dir, item) 825 item = presubmit.os.path.join(self.fake_root_dir, item)
822 presubmit.os.path.exists(item).AndReturn(True) 826 presubmit.os.path.exists(item).AndReturn(True)
823 presubmit.os.path.isdir(item).AndReturn(False) 827 presubmit.os.path.isdir(item).AndReturn(False)
824 presubmit.scm.SVN.GetFileProperty(item, 'svn:mime-type').AndReturn(None) 828 presubmit.scm.SVN.GetFileProperty(item, 'svn:mime-type').AndReturn(None)
825 self.mox.ReplayAll() 829 self.mox.ReplayAll()
826 830
827 change = presubmit.SvnChange('mychange', '', self.fake_root_dir, files, 0, 831 change = presubmit.SvnChange('mychange', '', self.fake_root_dir, files, 0,
828 0) 832 0)
829 input_api = presubmit.InputApi(change, 833 input_api = presubmit.InputApi(change,
830 presubmit.os.path.join(self.fake_root_dir, 834 presubmit.os.path.join(self.fake_root_dir,
831 'PRESUBMIT.py'), 835 'PRESUBMIT.py'),
832 False) 836 False)
833 got_files = input_api.AffectedSourceFiles(FilterSourceFile) 837 got_files = input_api.AffectedSourceFiles(FilterSourceFile)
834 self.assertEquals(len(got_files), 2) 838 self.assertEquals(len(got_files), 2)
835 self.assertEquals(got_files[0].LocalPath(), 'eeaee') 839 self.assertEquals(got_files[0].LocalPath(), 'eeaee')
836 self.assertEquals(got_files[1].LocalPath(), 'eeabee') 840 self.assertEquals(got_files[1].LocalPath(), 'eeabee')
837 841
838 def testLambdaFilter(self): 842 def testLambdaFilter(self):
839 white_list = presubmit.InputApi.DEFAULT_BLACK_LIST + (r".*?a.*?",) 843 white_list = presubmit.InputApi.DEFAULT_BLACK_LIST + (r".*?a.*?",)
840 black_list = [r".*?b.*?"] 844 black_list = [r".*?b.*?"]
841 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee'), ('M', 'eecaee')] 845 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee'), ('M', 'eecaee')]
842 for (action, item) in files: 846 for _, item in files:
843 item = presubmit.os.path.join(self.fake_root_dir, item) 847 item = presubmit.os.path.join(self.fake_root_dir, item)
844 presubmit.os.path.exists(item).AndReturn(True) 848 presubmit.os.path.exists(item).AndReturn(True)
845 presubmit.os.path.isdir(item).AndReturn(False) 849 presubmit.os.path.isdir(item).AndReturn(False)
846 presubmit.scm.SVN.GetFileProperty(item, 'svn:mime-type').AndReturn(None) 850 presubmit.scm.SVN.GetFileProperty(item, 'svn:mime-type').AndReturn(None)
847 self.mox.ReplayAll() 851 self.mox.ReplayAll()
848 852
849 change = presubmit.SvnChange('mychange', '', self.fake_root_dir, files, 0, 853 change = presubmit.SvnChange('mychange', '', self.fake_root_dir, files, 0,
850 0) 854 0)
851 input_api = presubmit.InputApi(change, './PRESUBMIT.py', False) 855 input_api = presubmit.InputApi(change, './PRESUBMIT.py', False)
852 # Sample usage of overiding the default white and black lists. 856 # Sample usage of overiding the default white and black lists.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 presubmit.gclient_utils.FileRead(path, 'x').AndReturn(None) 925 presubmit.gclient_utils.FileRead(path, 'x').AndReturn(None)
922 self.mox.ReplayAll() 926 self.mox.ReplayAll()
923 927
924 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')], 928 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')],
925 0, 0) 929 0, 0)
926 input_api = presubmit.InputApi( 930 input_api = presubmit.InputApi(
927 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False) 931 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False)
928 input_api.ReadFile(path, 'x') 932 input_api.ReadFile(path, 'x')
929 933
930 def testReadFileAffectedFileDenied(self): 934 def testReadFileAffectedFileDenied(self):
931 file = presubmit.AffectedFile('boo', 'M', 'Unrelated') 935 fileobj = presubmit.AffectedFile('boo', 'M', 'Unrelated')
932 self.mox.ReplayAll() 936 self.mox.ReplayAll()
933 937
934 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')], 938 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')],
935 0, 0) 939 0, 0)
936 input_api = presubmit.InputApi( 940 input_api = presubmit.InputApi(
937 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False) 941 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False)
938 self.assertRaises(IOError, input_api.ReadFile, file, 'x') 942 self.assertRaises(IOError, input_api.ReadFile, fileobj, 'x')
939 943
940 def testReadFileAffectedFileAccepted(self): 944 def testReadFileAffectedFileAccepted(self):
941 file = presubmit.AffectedFile('AA/boo', 'M', self.fake_root_dir) 945 fileobj = presubmit.AffectedFile('AA/boo', 'M', self.fake_root_dir)
942 presubmit.gclient_utils.FileRead(file.AbsoluteLocalPath(), 'x' 946 presubmit.gclient_utils.FileRead(fileobj.AbsoluteLocalPath(), 'x'
943 ).AndReturn(None) 947 ).AndReturn(None)
944 self.mox.ReplayAll() 948 self.mox.ReplayAll()
945 949
946 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')], 950 change = presubmit.Change('foo', 'foo', self.fake_root_dir, [('M', 'AA')],
947 0, 0) 951 0, 0)
948 input_api = presubmit.InputApi( 952 input_api = presubmit.InputApi(
949 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False) 953 change, presubmit.os.path.join(self.fake_root_dir, '/p'), False)
950 input_api.ReadFile(file, 'x') 954 input_api.ReadFile(fileobj, 'x')
951 955
952 956
953 class OuputApiUnittest(PresubmitTestsBase): 957 class OuputApiUnittest(PresubmitTestsBase):
954 """Tests presubmit.OutputApi.""" 958 """Tests presubmit.OutputApi."""
955 def testMembersChanged(self): 959 def testMembersChanged(self):
956 self.mox.ReplayAll() 960 self.mox.ReplayAll()
957 members = [ 961 members = [
958 'MailTextResult', 'PresubmitError', 'PresubmitNotifyResult', 962 'MailTextResult', 'PresubmitError', 'PresubmitNotifyResult',
959 'PresubmitPromptWarning', 'PresubmitResult', 963 'PresubmitPromptWarning', 'PresubmitResult',
960 ] 964 ]
(...skipping 21 matching lines...) Expand all
982 error = presubmit.OutputApi.PresubmitError('!!!') 986 error = presubmit.OutputApi.PresubmitError('!!!')
983 self.failIf(error._Handle(output, unused_input)) 987 self.failIf(error._Handle(output, unused_input))
984 self.failUnless(output.getvalue().count('!!!')) 988 self.failUnless(output.getvalue().count('!!!'))
985 989
986 output = StringIO.StringIO() 990 output = StringIO.StringIO()
987 notify = presubmit.OutputApi.PresubmitNotifyResult('?see?') 991 notify = presubmit.OutputApi.PresubmitNotifyResult('?see?')
988 self.failUnless(notify._Handle(output, unused_input)) 992 self.failUnless(notify._Handle(output, unused_input))
989 self.failUnless(output.getvalue().count('?see?')) 993 self.failUnless(output.getvalue().count('?see?'))
990 994
991 output = StringIO.StringIO() 995 output = StringIO.StringIO()
992 input = StringIO.StringIO('y') 996 input_buf = StringIO.StringIO('y')
993 warning = presubmit.OutputApi.PresubmitPromptWarning('???') 997 warning = presubmit.OutputApi.PresubmitPromptWarning('???')
994 self.failUnless(warning._Handle(output, input)) 998 self.failUnless(warning._Handle(output, input_buf))
995 self.failUnless(output.getvalue().count('???')) 999 self.failUnless(output.getvalue().count('???'))
996 1000
997 output = StringIO.StringIO() 1001 output = StringIO.StringIO()
998 input = StringIO.StringIO('n') 1002 input_buf = StringIO.StringIO('n')
999 warning = presubmit.OutputApi.PresubmitPromptWarning('???') 1003 warning = presubmit.OutputApi.PresubmitPromptWarning('???')
1000 self.failIf(warning._Handle(output, input)) 1004 self.failIf(warning._Handle(output, input_buf))
1001 self.failUnless(output.getvalue().count('???')) 1005 self.failUnless(output.getvalue().count('???'))
1002 1006
1003 output = StringIO.StringIO() 1007 output = StringIO.StringIO()
1004 input = StringIO.StringIO('\n') 1008 input_buf = StringIO.StringIO('\n')
1005 warning = presubmit.OutputApi.PresubmitPromptWarning('???') 1009 warning = presubmit.OutputApi.PresubmitPromptWarning('???')
1006 self.failIf(warning._Handle(output, input)) 1010 self.failIf(warning._Handle(output, input_buf))
1007 self.failUnless(output.getvalue().count('???')) 1011 self.failUnless(output.getvalue().count('???'))
1008 1012
1009 1013
1010 class AffectedFileUnittest(PresubmitTestsBase): 1014 class AffectedFileUnittest(PresubmitTestsBase):
1011 def testMembersChanged(self): 1015 def testMembersChanged(self):
1012 self.mox.ReplayAll() 1016 self.mox.ReplayAll()
1013 members = [ 1017 members = [
1014 'AbsoluteLocalPath', 'Action', 'IsDirectory', 'IsTextFile', 'LocalPath', 1018 'AbsoluteLocalPath', 'Action', 'IsDirectory', 'IsTextFile', 'LocalPath',
1015 'NewContents', 'OldContents', 'OldFileTempPath', 'Property', 'ServerPath', 1019 'NewContents', 'OldContents', 'OldFileTempPath', 'Property', 'ServerPath',
1016 ] 1020 ]
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 def testIsDirectory(self): 1061 def testIsDirectory(self):
1058 presubmit.os.path.exists('foo.cc').AndReturn(True) 1062 presubmit.os.path.exists('foo.cc').AndReturn(True)
1059 presubmit.os.path.isdir('foo.cc').AndReturn(True) 1063 presubmit.os.path.isdir('foo.cc').AndReturn(True)
1060 self.mox.ReplayAll() 1064 self.mox.ReplayAll()
1061 affected_file = presubmit.SvnAffectedFile('foo.cc', 'A') 1065 affected_file = presubmit.SvnAffectedFile('foo.cc', 'A')
1062 # Verify cache coherency. 1066 # Verify cache coherency.
1063 self.failUnless(affected_file.IsDirectory()) 1067 self.failUnless(affected_file.IsDirectory())
1064 self.failUnless(affected_file.IsDirectory()) 1068 self.failUnless(affected_file.IsDirectory())
1065 1069
1066 def testIsTextFile(self): 1070 def testIsTextFile(self):
1067 list = [presubmit.SvnAffectedFile('foo/blat.txt', 'M'), 1071 files = [presubmit.SvnAffectedFile('foo/blat.txt', 'M'),
1068 presubmit.SvnAffectedFile('foo/binary.blob', 'M'), 1072 presubmit.SvnAffectedFile('foo/binary.blob', 'M'),
1069 presubmit.SvnAffectedFile('blat/flop.txt', 'D')] 1073 presubmit.SvnAffectedFile('blat/flop.txt', 'D')]
1070 blat = presubmit.os.path.join('foo', 'blat.txt') 1074 blat = presubmit.os.path.join('foo', 'blat.txt')
1071 blob = presubmit.os.path.join('foo', 'binary.blob') 1075 blob = presubmit.os.path.join('foo', 'binary.blob')
1072 presubmit.os.path.exists(blat).AndReturn(True) 1076 presubmit.os.path.exists(blat).AndReturn(True)
1073 presubmit.os.path.isdir(blat).AndReturn(False) 1077 presubmit.os.path.isdir(blat).AndReturn(False)
1074 presubmit.os.path.exists(blob).AndReturn(True) 1078 presubmit.os.path.exists(blob).AndReturn(True)
1075 presubmit.os.path.isdir(blob).AndReturn(False) 1079 presubmit.os.path.isdir(blob).AndReturn(False)
1076 presubmit.scm.SVN.GetFileProperty(blat, 'svn:mime-type').AndReturn(None) 1080 presubmit.scm.SVN.GetFileProperty(blat, 'svn:mime-type').AndReturn(None)
1077 presubmit.scm.SVN.GetFileProperty(blob, 'svn:mime-type' 1081 presubmit.scm.SVN.GetFileProperty(blob, 'svn:mime-type'
1078 ).AndReturn('application/octet-stream') 1082 ).AndReturn('application/octet-stream')
1079 self.mox.ReplayAll() 1083 self.mox.ReplayAll()
1080 1084
1081 output = filter(lambda x: x.IsTextFile(), list) 1085 output = filter(lambda x: x.IsTextFile(), files)
1082 self.failUnless(len(output) == 1) 1086 self.failUnless(len(output) == 1)
1083 self.failUnless(list[0] == output[0]) 1087 self.failUnless(files[0] == output[0])
1084 1088
1085 1089
1086 class GclChangeUnittest(PresubmitTestsBase): 1090 class GclChangeUnittest(PresubmitTestsBase):
1087 def testMembersChanged(self): 1091 def testMembersChanged(self):
1088 members = [ 1092 members = [
1089 'AbsoluteLocalPaths', 'AffectedFiles', 'AffectedTextFiles', 1093 'AbsoluteLocalPaths', 'AffectedFiles', 'AffectedTextFiles',
1090 'DescriptionText', 'FullDescriptionText', 'LocalPaths', 'Name', 1094 'DescriptionText', 'FullDescriptionText', 'LocalPaths', 'Name',
1091 'RepositoryRoot', 'RightHandSideLines', 'ServerPaths', 1095 'RepositoryRoot', 'RightHandSideLines', 'ServerPaths',
1092 'issue', 'patchset', 'scm', 'tags', 1096 'issue', 'patchset', 'scm', 'tags',
1093 ] 1097 ]
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 input_api2.ReadFile(affected_file2, 'rb').AndReturn(content2) 1209 input_api2.ReadFile(affected_file2, 'rb').AndReturn(content2)
1206 affected_file2.LocalPath().AndReturn('bar.cc') 1210 affected_file2.LocalPath().AndReturn('bar.cc')
1207 self.mox.ReplayAll() 1211 self.mox.ReplayAll()
1208 1212
1209 results = check(input_api1, presubmit.OutputApi) 1213 results = check(input_api1, presubmit.OutputApi)
1210 self.assertEquals(results, []) 1214 self.assertEquals(results, [])
1211 results2 = check(input_api2, presubmit.OutputApi) 1215 results2 = check(input_api2, presubmit.OutputApi)
1212 self.assertEquals(len(results2), 1) 1216 self.assertEquals(len(results2), 1)
1213 self.assertEquals(results2[0].__class__, error_type) 1217 self.assertEquals(results2[0].__class__, error_type)
1214 1218
1215 def SvnPropertyTest(self, check, property, value1, value2, committing, 1219 def SvnPropertyTest(self, check, property_name, value1, value2, committing,
1216 error_type, use_source_file): 1220 error_type, use_source_file):
1217 change1 = presubmit.SvnChange('mychange', '', self.fake_root_dir, [], 0, 0) 1221 change1 = presubmit.SvnChange('mychange', '', self.fake_root_dir, [], 0, 0)
1218 input_api1 = self.MockInputApi(change1, committing) 1222 input_api1 = self.MockInputApi(change1, committing)
1219 files1 = [ 1223 files1 = [
1220 presubmit.SvnAffectedFile('foo/bar.cc', 'A'), 1224 presubmit.SvnAffectedFile('foo/bar.cc', 'A'),
1221 presubmit.SvnAffectedFile('foo.cc', 'M'), 1225 presubmit.SvnAffectedFile('foo.cc', 'M'),
1222 ] 1226 ]
1223 if use_source_file: 1227 if use_source_file:
1224 input_api1.AffectedSourceFiles(None).AndReturn(files1) 1228 input_api1.AffectedSourceFiles(None).AndReturn(files1)
1225 else: 1229 else:
1226 input_api1.AffectedFiles(include_deleted=False).AndReturn(files1) 1230 input_api1.AffectedFiles(include_deleted=False).AndReturn(files1)
1227 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo/bar.cc'), 1231 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo/bar.cc'),
1228 property).AndReturn(value1) 1232 property_name).AndReturn(value1)
1229 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo.cc'), 1233 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo.cc'),
1230 property).AndReturn(value1) 1234 property_name).AndReturn(value1)
1231 change2 = presubmit.SvnChange('mychange', '', self.fake_root_dir, [], 0, 0) 1235 change2 = presubmit.SvnChange('mychange', '', self.fake_root_dir, [], 0, 0)
1232 input_api2 = self.MockInputApi(change2, committing) 1236 input_api2 = self.MockInputApi(change2, committing)
1233 files2 = [ 1237 files2 = [
1234 presubmit.SvnAffectedFile('foo/bar.cc', 'A'), 1238 presubmit.SvnAffectedFile('foo/bar.cc', 'A'),
1235 presubmit.SvnAffectedFile('foo.cc', 'M'), 1239 presubmit.SvnAffectedFile('foo.cc', 'M'),
1236 ] 1240 ]
1237 if use_source_file: 1241 if use_source_file:
1238 input_api2.AffectedSourceFiles(None).AndReturn(files2) 1242 input_api2.AffectedSourceFiles(None).AndReturn(files2)
1239 else: 1243 else:
1240 input_api2.AffectedFiles(include_deleted=False).AndReturn(files2) 1244 input_api2.AffectedFiles(include_deleted=False).AndReturn(files2)
1241 1245
1242 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo/bar.cc'), 1246 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo/bar.cc'),
1243 property).AndReturn(value2) 1247 property_name).AndReturn(value2)
1244 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo.cc'), 1248 presubmit.scm.SVN.GetFileProperty(presubmit.normpath('foo.cc'),
1245 property).AndReturn(value2) 1249 property_name).AndReturn(value2)
1246 self.mox.ReplayAll() 1250 self.mox.ReplayAll()
1247 1251
1248 results1 = check(input_api1, presubmit.OutputApi, None) 1252 results1 = check(input_api1, presubmit.OutputApi, None)
1249 self.assertEquals(results1, []) 1253 self.assertEquals(results1, [])
1250 results2 = check(input_api2, presubmit.OutputApi, None) 1254 results2 = check(input_api2, presubmit.OutputApi, None)
1251 self.assertEquals(len(results2), 1) 1255 self.assertEquals(len(results2), 1)
1252 self.assertEquals(results2[0].__class__, error_type) 1256 self.assertEquals(results2[0].__class__, error_type)
1253 1257
1254 def testCannedCheckChangeHasBugField(self): 1258 def testCannedCheckChangeHasBugField(self):
1255 self.DescriptionTest(presubmit_canned_checks.CheckChangeHasBugField, 1259 self.DescriptionTest(presubmit_canned_checks.CheckChangeHasBugField,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 results1 = presubmit_canned_checks.CheckChangeHasNoTabs(input_api1, 1368 results1 = presubmit_canned_checks.CheckChangeHasNoTabs(input_api1,
1365 presubmit.OutputApi, None) 1369 presubmit.OutputApi, None)
1366 self.assertEquals(len(results1), 1) 1370 self.assertEquals(len(results1), 1)
1367 self.assertEquals(results1[0].__class__, 1371 self.assertEquals(results1[0].__class__,
1368 presubmit.OutputApi.PresubmitPromptWarning) 1372 presubmit.OutputApi.PresubmitPromptWarning)
1369 self.assertEquals(results1[0]._long_text, 1373 self.assertEquals(results1[0]._long_text,
1370 'makefile.foo, line 46') 1374 'makefile.foo, line 46')
1371 1375
1372 1376
1373 def testCannedCheckLongLines(self): 1377 def testCannedCheckLongLines(self):
1374 check = lambda x,y,z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) 1378 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
1375 self.ContentTest(check, '', 'blah blah blah', 1379 self.ContentTest(check, '', 'blah blah blah',
1376 presubmit.OutputApi.PresubmitPromptWarning) 1380 presubmit.OutputApi.PresubmitPromptWarning)
1377 1381
1378 def testCheckChangeSvnEolStyleCommit(self): 1382 def testCheckChangeSvnEolStyleCommit(self):
1379 # Test CheckSvnProperty at the same time. 1383 # Test CheckSvnProperty at the same time.
1380 self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle, 1384 self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle,
1381 'svn:eol-style', 'LF', '', True, 1385 'svn:eol-style', 'LF', '', True,
1382 presubmit.OutputApi.PresubmitError, True) 1386 presubmit.OutputApi.PresubmitError, True)
1383 1387
1384 def testCheckChangeSvnEolStyleUpload(self): 1388 def testCheckChangeSvnEolStyleUpload(self):
1385 self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle, 1389 self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle,
1386 'svn:eol-style', 'LF', '', False, 1390 'svn:eol-style', 'LF', '', False,
1387 presubmit.OutputApi.PresubmitNotifyResult, True) 1391 presubmit.OutputApi.PresubmitNotifyResult, True)
1388 1392
1389 def _LicenseCheck(self, text, license, committing, expected_result, **kwargs): 1393 def _LicenseCheck(self, text, license_text, committing, expected_result,
1394 **kwargs):
1390 change = self.mox.CreateMock(presubmit.SvnChange) 1395 change = self.mox.CreateMock(presubmit.SvnChange)
1391 change.scm = 'svn' 1396 change.scm = 'svn'
1392 input_api = self.MockInputApi(change, committing) 1397 input_api = self.MockInputApi(change, committing)
1393 affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile) 1398 affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile)
1394 input_api.AffectedSourceFiles(42).AndReturn([affected_file]) 1399 input_api.AffectedSourceFiles(42).AndReturn([affected_file])
1395 input_api.ReadFile(affected_file, 'rb').AndReturn(text) 1400 input_api.ReadFile(affected_file, 'rb').AndReturn(text)
1396 if expected_result: 1401 if expected_result:
1397 affected_file.LocalPath().AndReturn('bleh') 1402 affected_file.LocalPath().AndReturn('bleh')
1398 1403
1399 self.mox.ReplayAll() 1404 self.mox.ReplayAll()
1400 result = presubmit_canned_checks.CheckLicense( 1405 result = presubmit_canned_checks.CheckLicense(
1401 input_api, presubmit.OutputApi, license, source_file_filter=42, 1406 input_api, presubmit.OutputApi, license_text,
1407 source_file_filter=42,
1402 **kwargs) 1408 **kwargs)
1403 if expected_result: 1409 if expected_result:
1404 self.assertEqual(len(result), 1) 1410 self.assertEqual(len(result), 1)
1405 self.assertEqual(result[0].__class__, expected_result) 1411 self.assertEqual(result[0].__class__, expected_result)
1406 else: 1412 else:
1407 self.assertEqual(result, []) 1413 self.assertEqual(result, [])
1408 1414
1409 def testCheckLicenseSuccess(self): 1415 def testCheckLicenseSuccess(self):
1410 text = ( 1416 text = (
1411 "#!/bin/python\n" 1417 "#!/bin/python\n"
1412 "# Copyright (c) 2037 Nobody.\n" 1418 "# Copyright (c) 2037 Nobody.\n"
1413 "# All Rights Reserved.\n" 1419 "# All Rights Reserved.\n"
1414 "print 'foo'\n" 1420 "print 'foo'\n"
1415 ) 1421 )
1416 license = ( 1422 license_text = (
1417 r".*? Copyright \(c\) 2037 Nobody." "\n" 1423 r".*? Copyright \(c\) 2037 Nobody." "\n"
1418 r".*? All Rights Reserved\." "\n" 1424 r".*? All Rights Reserved\." "\n"
1419 ) 1425 )
1420 self._LicenseCheck(text, license, True, None) 1426 self._LicenseCheck(text, license_text, True, None)
1421 1427
1422 def testCheckLicenseFailCommit(self): 1428 def testCheckLicenseFailCommit(self):
1423 text = ( 1429 text = (
1424 "#!/bin/python\n" 1430 "#!/bin/python\n"
1425 "# Copyright (c) 2037 Nobody.\n" 1431 "# Copyright (c) 2037 Nobody.\n"
1426 "# All Rights Reserved.\n" 1432 "# All Rights Reserved.\n"
1427 "print 'foo'\n" 1433 "print 'foo'\n"
1428 ) 1434 )
1429 license = ( 1435 license_text = (
1430 r".*? Copyright \(c\) 0007 Nobody." "\n" 1436 r".*? Copyright \(c\) 0007 Nobody." "\n"
1431 r".*? All Rights Reserved\." "\n" 1437 r".*? All Rights Reserved\." "\n"
1432 ) 1438 )
1433 self._LicenseCheck(text, license, True, 1439 self._LicenseCheck(text, license_text, True,
1434 presubmit.OutputApi.PresubmitPromptWarning) 1440 presubmit.OutputApi.PresubmitPromptWarning)
1435 1441
1436 def testCheckLicenseFailUpload(self): 1442 def testCheckLicenseFailUpload(self):
1437 text = ( 1443 text = (
1438 "#!/bin/python\n" 1444 "#!/bin/python\n"
1439 "# Copyright (c) 2037 Nobody.\n" 1445 "# Copyright (c) 2037 Nobody.\n"
1440 "# All Rights Reserved.\n" 1446 "# All Rights Reserved.\n"
1441 "print 'foo'\n" 1447 "print 'foo'\n"
1442 ) 1448 )
1443 license = ( 1449 license_text = (
1444 r".*? Copyright \(c\) 0007 Nobody." "\n" 1450 r".*? Copyright \(c\) 0007 Nobody." "\n"
1445 r".*? All Rights Reserved\." "\n" 1451 r".*? All Rights Reserved\." "\n"
1446 ) 1452 )
1447 self._LicenseCheck(text, license, False, 1453 self._LicenseCheck(text, license_text, False,
1448 presubmit.OutputApi.PresubmitNotifyResult) 1454 presubmit.OutputApi.PresubmitNotifyResult)
1449 1455
1450 def testCheckLicenseEmptySuccess(self): 1456 def testCheckLicenseEmptySuccess(self):
1451 text = '' 1457 text = ''
1452 license = ( 1458 license_text = (
1453 r".*? Copyright \(c\) 2037 Nobody." "\n" 1459 r".*? Copyright \(c\) 2037 Nobody." "\n"
1454 r".*? All Rights Reserved\." "\n" 1460 r".*? All Rights Reserved\." "\n"
1455 ) 1461 )
1456 self._LicenseCheck(text, license, True, None, accept_empty_files=True) 1462 self._LicenseCheck(text, license_text, True, None, accept_empty_files=True)
1457 1463
1458 def testCannedCheckSvnAccidentalSubmission(self): 1464 def testCannedCheckSvnAccidentalSubmission(self):
1459 modified_dir_file = 'foo/' 1465 modified_dir_file = 'foo/'
1460 accidental_submssion_file = 'foo/bar.cc' 1466 accidental_submssion_file = 'foo/bar.cc'
1461 1467
1462 change = self.mox.CreateMock(presubmit.SvnChange) 1468 change = self.mox.CreateMock(presubmit.SvnChange)
1463 change.scm = 'svn' 1469 change.scm = 'svn'
1464 change.GetModifiedFiles().AndReturn([modified_dir_file]) 1470 change.GetModifiedFiles().AndReturn([modified_dir_file])
1465 change.GetAllModifiedFiles().AndReturn([modified_dir_file, 1471 change.GetAllModifiedFiles().AndReturn([modified_dir_file,
1466 accidental_submssion_file]) 1472 accidental_submssion_file])
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 results = presubmit_canned_checks.CheckBuildbotPendingBuilds( 1754 results = presubmit_canned_checks.CheckBuildbotPendingBuilds(
1749 input_api, presubmit.OutputApi, 'uurl', 2, ('foo')) 1755 input_api, presubmit.OutputApi, 'uurl', 2, ('foo'))
1750 self.assertEquals(len(results), 1) 1756 self.assertEquals(len(results), 1)
1751 self.assertEquals(results[0].__class__, 1757 self.assertEquals(results[0].__class__,
1752 presubmit.OutputApi.PresubmitNotifyResult) 1758 presubmit.OutputApi.PresubmitNotifyResult)
1753 1759
1754 1760
1755 if __name__ == '__main__': 1761 if __name__ == '__main__':
1756 import unittest 1762 import unittest
1757 unittest.main() 1763 unittest.main()
OLDNEW
« no previous file with comments | « tests/gclient_utils_test.py ('k') | tests/scm_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698