OLD | NEW |
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 exceptions | 8 import exceptions |
9 import random | 9 import random |
10 import string | 10 import string |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 ).AndReturn(self.presubmit_text) | 373 ).AndReturn(self.presubmit_text) |
374 self.mox.ReplayAll() | 374 self.mox.ReplayAll() |
375 | 375 |
376 ci = presubmit.gcl.ChangeInfo(name='mychange', issue=0, patchset=0, | 376 ci = presubmit.gcl.ChangeInfo(name='mychange', issue=0, patchset=0, |
377 description='\n'.join(description_lines), | 377 description='\n'.join(description_lines), |
378 files=files) | 378 files=files) |
379 | 379 |
380 output = StringIO.StringIO() | 380 output = StringIO.StringIO() |
381 input = StringIO.StringIO('n\n') # say no to the warning | 381 input = StringIO.StringIO('n\n') # say no to the warning |
382 self.failIf(presubmit.DoPresubmitChecks(ci, False, True, output, input, | 382 self.failIf(presubmit.DoPresubmitChecks(ci, False, True, output, input, |
383 None, False)) | 383 None, True)) |
384 self.assertEqual(output.getvalue().count('??'), 2) | 384 self.assertEqual(output.getvalue().count('??'), 2) |
385 | 385 |
386 output = StringIO.StringIO() | 386 output = StringIO.StringIO() |
387 input = StringIO.StringIO('y\n') # say yes to the warning | 387 input = StringIO.StringIO('y\n') # say yes to the warning |
388 self.failUnless(presubmit.DoPresubmitChecks(ci, | 388 self.failUnless(presubmit.DoPresubmitChecks(ci, |
389 False, | 389 False, |
390 True, | 390 True, |
391 output, | 391 output, |
392 input, | 392 input, |
393 None, | 393 None, |
394 False)) | 394 True)) |
395 self.assertEquals(output.getvalue().count('??'), 2) | 395 self.assertEquals(output.getvalue().count('??'), 2) |
396 | 396 |
397 def testDoPresubmitChecksNoWarningPromptIfErrors(self): | 397 def testDoPresubmitChecksNoWarningPromptIfErrors(self): |
398 join = presubmit.os.path.join | 398 join = presubmit.os.path.join |
399 description_lines = ('Hello there', | 399 description_lines = ('Hello there', |
400 'this is a change', | 400 'this is a change', |
401 'NOSUCHKEY=http://tracker/123', | 401 'NOSUCHKEY=http://tracker/123', |
402 'REALLYNOSUCHKEY=http://tracker/123') | 402 'REALLYNOSUCHKEY=http://tracker/123') |
403 files = [ | 403 files = [ |
404 ['A', join('haspresubmit', 'blat.cc')], | 404 ['A', join('haspresubmit', 'blat.cc')], |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 test_result.errors = 0 | 1386 test_result.errors = 0 |
1387 self.mox.ReplayAll() | 1387 self.mox.ReplayAll() |
1388 | 1388 |
1389 results = presubmit_canned_checks.RunPythonUnitTests( | 1389 results = presubmit_canned_checks.RunPythonUnitTests( |
1390 input_api, presubmit.OutputApi, ['test_module']) | 1390 input_api, presubmit.OutputApi, ['test_module']) |
1391 self.assertEquals(len(results), 0) | 1391 self.assertEquals(len(results), 0) |
1392 | 1392 |
1393 | 1393 |
1394 if __name__ == '__main__': | 1394 if __name__ == '__main__': |
1395 unittest.main() | 1395 unittest.main() |
OLD | NEW |