| OLD | NEW |
| 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 import StringIO | 8 import StringIO |
| 9 | 9 |
| 10 # Fixes include path. | 10 # Fixes include path. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 presubmit.os.getcwd = self.RootDir | 50 presubmit.os.getcwd = self.RootDir |
| 51 presubmit.os.chdir = MockChdir | 51 presubmit.os.chdir = MockChdir |
| 52 self.mox.StubOutWithMock(presubmit.scm.SVN, 'CaptureInfo') | 52 self.mox.StubOutWithMock(presubmit.scm.SVN, 'CaptureInfo') |
| 53 self.mox.StubOutWithMock(presubmit.scm.SVN, 'GetFileProperty') | 53 self.mox.StubOutWithMock(presubmit.scm.SVN, 'GetFileProperty') |
| 54 self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileRead') | 54 self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileRead') |
| 55 self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileWrite') | 55 self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileWrite') |
| 56 | 56 |
| 57 | 57 |
| 58 class PresubmitUnittest(PresubmitTestsBase): | 58 class PresubmitUnittest(PresubmitTestsBase): |
| 59 """General presubmit_support.py tests (excluding InputApi and OutputApi).""" | 59 """General presubmit_support.py tests (excluding InputApi and OutputApi).""" |
| 60 |
| 61 _INHERIT_SETTINGS = 'inherit-review-settings-ok' |
| 62 |
| 60 def testMembersChanged(self): | 63 def testMembersChanged(self): |
| 61 self.mox.ReplayAll() | 64 self.mox.ReplayAll() |
| 62 members = [ | 65 members = [ |
| 63 'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks', | 66 'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks', |
| 64 'GetTrySlavesExecuter', 'GitAffectedFile', 'GitChange', | 67 'GetTrySlavesExecuter', 'GitAffectedFile', 'GitChange', |
| 65 'InputApi', 'ListRelevantPresubmitFiles', 'Main', | 68 'InputApi', 'ListRelevantPresubmitFiles', 'Main', |
| 66 'NotImplementedException', 'OutputApi', 'ParseFiles', | 69 'NotImplementedException', 'OutputApi', 'ParseFiles', |
| 67 'PresubmitExecuter', 'PromptYesNo', 'ScanSubDirs', | 70 'PresubmitExecuter', 'PromptYesNo', 'ScanSubDirs', |
| 68 'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO', | 71 'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO', |
| 69 'exceptions', 'fnmatch', 'gcl', 'gclient_utils', 'glob', 'json', | 72 'exceptions', 'fnmatch', 'gcl', 'gclient_utils', 'glob', 'json', |
| 70 'logging', 'marshal', 'normpath', 'optparse', 'os', 'pickle', | 73 'logging', 'marshal', 'normpath', 'optparse', 'os', 'pickle', |
| 71 'presubmit_canned_checks', 'random', 're', 'scm', 'subprocess', 'sys', | 74 'presubmit_canned_checks', 'random', 're', 'scm', 'subprocess', 'sys', |
| 72 'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2', | 75 'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2', |
| 73 'warnings', | 76 'warnings', |
| 74 ] | 77 ] |
| 75 # If this test fails, you should add the relevant test. | 78 # If this test fails, you should add the relevant test. |
| 76 self.compareMembers(presubmit, members) | 79 self.compareMembers(presubmit, members) |
| 77 | 80 |
| 78 def testListRelevantPresubmitFiles(self): | 81 def testListRelevantPresubmitFiles(self): |
| 79 join = presubmit.os.path.join | 82 join = presubmit.os.path.join |
| 80 files = [ | 83 files = [ |
| 81 'blat.cc', | 84 'blat.cc', |
| 82 join('foo', 'haspresubmit', 'yodle', 'smart.h'), | 85 join('foo', 'haspresubmit', 'yodle', 'smart.h'), |
| 83 join('moo', 'mat', 'gat', 'yo.h'), | 86 join('moo', 'mat', 'gat', 'yo.h'), |
| 84 join('foo', 'luck.h'), | 87 join('foo', 'luck.h'), |
| 85 ] | 88 ] |
| 89 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 90 self._INHERIT_SETTINGS) |
| 91 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 86 presubmit.os.path.isfile(join(self.fake_root_dir, | 92 presubmit.os.path.isfile(join(self.fake_root_dir, |
| 87 'PRESUBMIT.py')).AndReturn(True) | 93 'PRESUBMIT.py')).AndReturn(True) |
| 88 presubmit.os.path.isfile(join(self.fake_root_dir, 'foo', | 94 presubmit.os.path.isfile(join(self.fake_root_dir, 'foo', |
| 89 'PRESUBMIT.py')).AndReturn(False) | 95 'PRESUBMIT.py')).AndReturn(False) |
| 90 presubmit.os.path.isfile(join(self.fake_root_dir, 'foo', 'haspresubmit', | 96 presubmit.os.path.isfile(join(self.fake_root_dir, 'foo', 'haspresubmit', |
| 91 'PRESUBMIT.py')).AndReturn(True) | 97 'PRESUBMIT.py')).AndReturn(True) |
| 92 presubmit.os.path.isfile(join(self.fake_root_dir, 'foo', 'haspresubmit', | 98 presubmit.os.path.isfile(join(self.fake_root_dir, 'foo', 'haspresubmit', |
| 93 'yodle', 'PRESUBMIT.py')).AndReturn(True) | 99 'yodle', 'PRESUBMIT.py')).AndReturn(True) |
| 94 presubmit.os.path.isfile(join(self.fake_root_dir, 'moo', | 100 presubmit.os.path.isfile(join(self.fake_root_dir, 'moo', |
| 95 'PRESUBMIT.py')).AndReturn(False) | 101 'PRESUBMIT.py')).AndReturn(False) |
| 96 presubmit.os.path.isfile(join(self.fake_root_dir, 'moo', 'mat', | 102 presubmit.os.path.isfile(join(self.fake_root_dir, 'moo', 'mat', |
| 97 'PRESUBMIT.py')).AndReturn(False) | 103 'PRESUBMIT.py')).AndReturn(False) |
| 98 presubmit.os.path.isfile(join(self.fake_root_dir, 'moo', 'mat', 'gat', | 104 presubmit.os.path.isfile(join(self.fake_root_dir, 'moo', 'mat', 'gat', |
| 99 'PRESUBMIT.py')).AndReturn(False) | 105 'PRESUBMIT.py')).AndReturn(False) |
| 100 self.mox.ReplayAll() | 106 self.mox.ReplayAll() |
| 101 | 107 |
| 102 presubmit_files = presubmit.ListRelevantPresubmitFiles(files, | 108 presubmit_files = presubmit.ListRelevantPresubmitFiles(files, |
| 103 self.fake_root_dir) | 109 self.fake_root_dir) |
| 104 self.assertEqual(presubmit_files, | 110 self.assertEqual(presubmit_files, |
| 105 [ | 111 [ |
| 106 join(self.fake_root_dir, 'PRESUBMIT.py'), | 112 join(self.fake_root_dir, 'PRESUBMIT.py'), |
| 107 join(self.fake_root_dir, 'foo', 'haspresubmit', 'PRESUBMIT.py'), | 113 join(self.fake_root_dir, 'foo', 'haspresubmit', 'PRESUBMIT.py'), |
| 108 join(self.fake_root_dir, 'foo', 'haspresubmit', 'yodle', | 114 join(self.fake_root_dir, 'foo', 'haspresubmit', 'yodle', |
| 109 'PRESUBMIT.py') | 115 'PRESUBMIT.py') |
| 110 ]) | 116 ]) |
| 111 | 117 |
| 118 def testListRelevantPresubmitFilesInheritSettings(self): |
| 119 join = presubmit.os.path.join |
| 120 sys_root_dir = self._OS_SEP |
| 121 root_dir = join(sys_root_dir, 'foo', 'bar') |
| 122 files = [ |
| 123 'test.cc', |
| 124 join('moo', 'test2.cc'), |
| 125 join('zoo', 'test3.cc') |
| 126 ] |
| 127 inherit_path = presubmit.os.path.join(root_dir, self._INHERIT_SETTINGS) |
| 128 presubmit.os.path.isfile(inherit_path).AndReturn(True) |
| 129 presubmit.os.path.isfile(join(sys_root_dir, |
| 130 'PRESUBMIT.py')).AndReturn(False) |
| 131 presubmit.os.path.isfile(join(sys_root_dir, 'foo', |
| 132 'PRESUBMIT.py')).AndReturn(True) |
| 133 presubmit.os.path.isfile(join(sys_root_dir, 'foo', 'bar', |
| 134 'PRESUBMIT.py')).AndReturn(False) |
| 135 presubmit.os.path.isfile(join(sys_root_dir, 'foo', 'bar', 'moo', |
| 136 'PRESUBMIT.py')).AndReturn(True) |
| 137 presubmit.os.path.isfile(join(sys_root_dir, 'foo', 'bar', 'zoo', |
| 138 'PRESUBMIT.py')).AndReturn(False) |
| 139 self.mox.ReplayAll() |
| 140 |
| 141 presubmit_files = presubmit.ListRelevantPresubmitFiles(files, root_dir) |
| 142 self.assertEqual(presubmit_files, |
| 143 [ |
| 144 join(sys_root_dir, 'foo', 'PRESUBMIT.py'), |
| 145 join(sys_root_dir, 'foo', 'bar', 'moo', 'PRESUBMIT.py') |
| 146 ]) |
| 147 |
| 112 def testTagLineRe(self): | 148 def testTagLineRe(self): |
| 113 self.mox.ReplayAll() | 149 self.mox.ReplayAll() |
| 114 m = presubmit.Change._TAG_LINE_RE.match(' BUG =1223, 1445 \t') | 150 m = presubmit.Change._TAG_LINE_RE.match(' BUG =1223, 1445 \t') |
| 115 self.failUnless(m) | 151 self.failUnless(m) |
| 116 self.failUnlessEqual(m.group('key'), 'BUG') | 152 self.failUnlessEqual(m.group('key'), 'BUG') |
| 117 self.failUnlessEqual(m.group('value'), '1223, 1445') | 153 self.failUnlessEqual(m.group('value'), '1223, 1445') |
| 118 | 154 |
| 119 def testGclChange(self): | 155 def testGclChange(self): |
| 120 description_lines = ('Hello there', | 156 description_lines = ('Hello there', |
| 121 'this is a change', | 157 'this is a change', |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 def testDoPresubmitChecks(self): | 315 def testDoPresubmitChecks(self): |
| 280 join = presubmit.os.path.join | 316 join = presubmit.os.path.join |
| 281 description_lines = ('Hello there', | 317 description_lines = ('Hello there', |
| 282 'this is a change', | 318 'this is a change', |
| 283 'STORY=http://tracker/123') | 319 'STORY=http://tracker/123') |
| 284 files = [ | 320 files = [ |
| 285 ['A', join('haspresubmit', 'blat.cc')], | 321 ['A', join('haspresubmit', 'blat.cc')], |
| 286 ] | 322 ] |
| 287 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') | 323 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') |
| 288 root_path = join(self.fake_root_dir, 'PRESUBMIT.py') | 324 root_path = join(self.fake_root_dir, 'PRESUBMIT.py') |
| 325 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 326 self._INHERIT_SETTINGS) |
| 327 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 289 presubmit.os.path.isfile(root_path).AndReturn(True) | 328 presubmit.os.path.isfile(root_path).AndReturn(True) |
| 290 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) | 329 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) |
| 291 presubmit.gclient_utils.FileRead(root_path, | 330 presubmit.gclient_utils.FileRead(root_path, |
| 292 'rU').AndReturn(self.presubmit_text) | 331 'rU').AndReturn(self.presubmit_text) |
| 293 presubmit.gclient_utils.FileRead(haspresubmit_path, | 332 presubmit.gclient_utils.FileRead(haspresubmit_path, |
| 294 'rU').AndReturn(self.presubmit_text) | 333 'rU').AndReturn(self.presubmit_text) |
| 295 presubmit.random.randint(0, 4).AndReturn(1) | 334 presubmit.random.randint(0, 4).AndReturn(1) |
| 296 self.mox.ReplayAll() | 335 self.mox.ReplayAll() |
| 297 | 336 |
| 298 output = StringIO.StringIO() | 337 output = StringIO.StringIO() |
| 299 input = StringIO.StringIO('y\n') | 338 input = StringIO.StringIO('y\n') |
| 300 change = presubmit.Change('mychange', '\n'.join(description_lines), | 339 change = presubmit.Change('mychange', '\n'.join(description_lines), |
| 301 self.fake_root_dir, files, 0, 0) | 340 self.fake_root_dir, files, 0, 0) |
| 302 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input, | 341 self.failIf(presubmit.DoPresubmitChecks(change, False, True, output, input, |
| 303 None, False)) | 342 None, False)) |
| 304 self.assertEqual(output.getvalue().count('!!'), 2) | 343 self.assertEqual(output.getvalue().count('!!'), 2) |
| 305 | 344 |
| 306 def testDoPresubmitChecksPromptsAfterWarnings(self): | 345 def testDoPresubmitChecksPromptsAfterWarnings(self): |
| 307 join = presubmit.os.path.join | 346 join = presubmit.os.path.join |
| 308 description_lines = ('Hello there', | 347 description_lines = ('Hello there', |
| 309 'this is a change', | 348 'this is a change', |
| 310 'NOSUCHKEY=http://tracker/123') | 349 'NOSUCHKEY=http://tracker/123') |
| 311 files = [ | 350 files = [ |
| 312 ['A', join('haspresubmit', 'blat.cc')], | 351 ['A', join('haspresubmit', 'blat.cc')], |
| 313 ] | 352 ] |
| 314 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') | 353 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') |
| 315 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') | 354 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', 'PRESUBMIT.py') |
| 355 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 356 self._INHERIT_SETTINGS) |
| 316 for i in range(2): | 357 for i in range(2): |
| 358 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 317 presubmit.os.path.isfile(presubmit_path).AndReturn(True) | 359 presubmit.os.path.isfile(presubmit_path).AndReturn(True) |
| 318 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) | 360 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) |
| 319 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' | 361 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' |
| 320 ).AndReturn(self.presubmit_text) | 362 ).AndReturn(self.presubmit_text) |
| 321 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU' | 363 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU' |
| 322 ).AndReturn(self.presubmit_text) | 364 ).AndReturn(self.presubmit_text) |
| 323 presubmit.random.randint(0, 4).AndReturn(1) | 365 presubmit.random.randint(0, 4).AndReturn(1) |
| 324 presubmit.random.randint(0, 4).AndReturn(1) | 366 presubmit.random.randint(0, 4).AndReturn(1) |
| 325 self.mox.ReplayAll() | 367 self.mox.ReplayAll() |
| 326 | 368 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 343 description_lines = ('Hello there', | 385 description_lines = ('Hello there', |
| 344 'this is a change', | 386 'this is a change', |
| 345 'NOSUCHKEY=http://tracker/123', | 387 'NOSUCHKEY=http://tracker/123', |
| 346 'REALLYNOSUCHKEY=http://tracker/123') | 388 'REALLYNOSUCHKEY=http://tracker/123') |
| 347 files = [ | 389 files = [ |
| 348 ['A', join('haspresubmit', 'blat.cc')], | 390 ['A', join('haspresubmit', 'blat.cc')], |
| 349 ] | 391 ] |
| 350 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') | 392 presubmit_path = join(self.fake_root_dir, 'PRESUBMIT.py') |
| 351 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', | 393 haspresubmit_path = join(self.fake_root_dir, 'haspresubmit', |
| 352 'PRESUBMIT.py') | 394 'PRESUBMIT.py') |
| 395 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 396 self._INHERIT_SETTINGS) |
| 397 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 353 presubmit.os.path.isfile(presubmit_path).AndReturn(True) | 398 presubmit.os.path.isfile(presubmit_path).AndReturn(True) |
| 354 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) | 399 presubmit.os.path.isfile(haspresubmit_path).AndReturn(True) |
| 355 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' | 400 presubmit.gclient_utils.FileRead(presubmit_path, 'rU' |
| 356 ).AndReturn(self.presubmit_text) | 401 ).AndReturn(self.presubmit_text) |
| 357 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU').AndReturn( | 402 presubmit.gclient_utils.FileRead(haspresubmit_path, 'rU').AndReturn( |
| 358 self.presubmit_text) | 403 self.presubmit_text) |
| 359 presubmit.random.randint(0, 4).AndReturn(1) | 404 presubmit.random.randint(0, 4).AndReturn(1) |
| 360 self.mox.ReplayAll() | 405 self.mox.ReplayAll() |
| 361 | 406 |
| 362 output = StringIO.StringIO() | 407 output = StringIO.StringIO() |
| (...skipping 13 matching lines...) Expand all Loading... |
| 376 'STORY=http://tracker/123') | 421 'STORY=http://tracker/123') |
| 377 files = [ | 422 files = [ |
| 378 ['A', join('haspresubmit', 'blat.cc')], | 423 ['A', join('haspresubmit', 'blat.cc')], |
| 379 ] | 424 ] |
| 380 DEFAULT_SCRIPT = """ | 425 DEFAULT_SCRIPT = """ |
| 381 def CheckChangeOnUpload(input_api, output_api): | 426 def CheckChangeOnUpload(input_api, output_api): |
| 382 return [output_api.PresubmitError("!!")] | 427 return [output_api.PresubmitError("!!")] |
| 383 def CheckChangeOnCommit(input_api, output_api): | 428 def CheckChangeOnCommit(input_api, output_api): |
| 384 raise Exception("Test error") | 429 raise Exception("Test error") |
| 385 """ | 430 """ |
| 431 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 432 self._INHERIT_SETTINGS) |
| 433 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 386 presubmit.os.path.isfile(join(self.fake_root_dir, 'PRESUBMIT.py') | 434 presubmit.os.path.isfile(join(self.fake_root_dir, 'PRESUBMIT.py') |
| 387 ).AndReturn(False) | 435 ).AndReturn(False) |
| 388 presubmit.os.path.isfile(join(self.fake_root_dir, | 436 presubmit.os.path.isfile(join(self.fake_root_dir, |
| 389 'haspresubmit', | 437 'haspresubmit', |
| 390 'PRESUBMIT.py')).AndReturn(False) | 438 'PRESUBMIT.py')).AndReturn(False) |
| 391 presubmit.random.randint(0, 4).AndReturn(0) | 439 presubmit.random.randint(0, 4).AndReturn(0) |
| 392 self.mox.ReplayAll() | 440 self.mox.ReplayAll() |
| 393 | 441 |
| 394 output = StringIO.StringIO() | 442 output = StringIO.StringIO() |
| 395 input = StringIO.StringIO('y\n') | 443 input = StringIO.StringIO('y\n') |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 input_api.change.DescriptionText())] | 499 input_api.change.DescriptionText())] |
| 452 if (input_api.change.FullDescriptionText() != | 500 if (input_api.change.FullDescriptionText() != |
| 453 'Blah Blah\\n\\nSTORY=http://tracker.com/42\\nBUG=boo\\n'): | 501 'Blah Blah\\n\\nSTORY=http://tracker.com/42\\nBUG=boo\\n'): |
| 454 return [output_api.PresubmitError('Tag parsing failed. 5 ' + | 502 return [output_api.PresubmitError('Tag parsing failed. 5 ' + |
| 455 input_api.change.FullDescriptionText())] | 503 input_api.change.FullDescriptionText())] |
| 456 return [output_api.PresubmitNotifyResult(input_api.change.tags['STORY'])] | 504 return [output_api.PresubmitNotifyResult(input_api.change.tags['STORY'])] |
| 457 def CheckChangeOnCommit(input_api, output_api): | 505 def CheckChangeOnCommit(input_api, output_api): |
| 458 raise Exception("Test error") | 506 raise Exception("Test error") |
| 459 """ | 507 """ |
| 460 presubmit.random.randint(0, 4).AndReturn(1) | 508 presubmit.random.randint(0, 4).AndReturn(1) |
| 509 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 510 self._INHERIT_SETTINGS) |
| 511 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 461 self.mox.ReplayAll() | 512 self.mox.ReplayAll() |
| 462 | 513 |
| 463 output = StringIO.StringIO() | 514 output = StringIO.StringIO() |
| 464 input = StringIO.StringIO('y\n') | 515 input = StringIO.StringIO('y\n') |
| 465 change = presubmit.Change( | 516 change = presubmit.Change( |
| 466 'foo', "Blah Blah\n\nSTORY=http://tracker.com/42\nBUG=boo\n", | 517 'foo', "Blah Blah\n\nSTORY=http://tracker.com/42\nBUG=boo\n", |
| 467 self.fake_root_dir, None, 0, 0) | 518 self.fake_root_dir, None, 0, 0) |
| 468 self.failUnless(presubmit.DoPresubmitChecks(change, False, True, output, | 519 self.failUnless(presubmit.DoPresubmitChecks(change, False, True, output, |
| 469 input, DEFAULT_SCRIPT, False)) | 520 input, DEFAULT_SCRIPT, False)) |
| 470 self.assertEquals(output.getvalue(), | 521 self.assertEquals(output.getvalue(), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 497 self.assertEqual(result, | 548 self.assertEqual(result, |
| 498 executer.ExecPresubmitScript(self.presubmit_tryslave % | 549 executer.ExecPresubmitScript(self.presubmit_tryslave % |
| 499 str(result))) | 550 str(result))) |
| 500 | 551 |
| 501 def testDoGetTrySlaves(self): | 552 def testDoGetTrySlaves(self): |
| 502 join = presubmit.os.path.join | 553 join = presubmit.os.path.join |
| 503 filename = 'foo.cc' | 554 filename = 'foo.cc' |
| 504 filename_linux = join('linux_only', 'penguin.cc') | 555 filename_linux = join('linux_only', 'penguin.cc') |
| 505 root_presubmit = join(self.fake_root_dir, 'PRESUBMIT.py') | 556 root_presubmit = join(self.fake_root_dir, 'PRESUBMIT.py') |
| 506 linux_presubmit = join(self.fake_root_dir, 'linux_only', 'PRESUBMIT.py') | 557 linux_presubmit = join(self.fake_root_dir, 'linux_only', 'PRESUBMIT.py') |
| 558 inherit_path = presubmit.os.path.join(self.fake_root_dir, |
| 559 self._INHERIT_SETTINGS) |
| 507 | 560 |
| 561 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 508 presubmit.os.path.isfile(root_presubmit).AndReturn(True) | 562 presubmit.os.path.isfile(root_presubmit).AndReturn(True) |
| 509 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn( | 563 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn( |
| 510 self.presubmit_tryslave % '["win"]') | 564 self.presubmit_tryslave % '["win"]') |
| 511 | 565 |
| 566 presubmit.os.path.isfile(inherit_path).AndReturn(False) |
| 512 presubmit.os.path.isfile(root_presubmit).AndReturn(True) | 567 presubmit.os.path.isfile(root_presubmit).AndReturn(True) |
| 513 presubmit.os.path.isfile(linux_presubmit).AndReturn(True) | 568 presubmit.os.path.isfile(linux_presubmit).AndReturn(True) |
| 514 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn( | 569 presubmit.gclient_utils.FileRead(root_presubmit, 'rU').AndReturn( |
| 515 self.presubmit_tryslave % '["win"]') | 570 self.presubmit_tryslave % '["win"]') |
| 516 presubmit.gclient_utils.FileRead(linux_presubmit, 'rU').AndReturn( | 571 presubmit.gclient_utils.FileRead(linux_presubmit, 'rU').AndReturn( |
| 517 self.presubmit_tryslave % '["linux"]') | 572 self.presubmit_tryslave % '["linux"]') |
| 518 self.mox.ReplayAll() | 573 self.mox.ReplayAll() |
| 519 | 574 |
| 520 output = StringIO.StringIO() | 575 output = StringIO.StringIO() |
| 521 self.assertEqual(['win'], | 576 self.assertEqual(['win'], |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 results = presubmit_canned_checks.CheckBuildbotPendingBuilds( | 1659 results = presubmit_canned_checks.CheckBuildbotPendingBuilds( |
| 1605 input_api, presubmit.OutputApi, 'uurl', 2, ('foo')) | 1660 input_api, presubmit.OutputApi, 'uurl', 2, ('foo')) |
| 1606 self.assertEquals(len(results), 1) | 1661 self.assertEquals(len(results), 1) |
| 1607 self.assertEquals(results[0].__class__, | 1662 self.assertEquals(results[0].__class__, |
| 1608 presubmit.OutputApi.PresubmitNotifyResult) | 1663 presubmit.OutputApi.PresubmitNotifyResult) |
| 1609 | 1664 |
| 1610 | 1665 |
| 1611 if __name__ == '__main__': | 1666 if __name__ == '__main__': |
| 1612 import unittest | 1667 import unittest |
| 1613 unittest.main() | 1668 unittest.main() |
| OLD | NEW |