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.py and presubmit_canned_checks.py.""" | 6 """Unit tests for presubmit.py and presubmit_canned_checks.py.""" |
7 | 7 |
8 import os | 8 import os |
9 import StringIO | 9 import StringIO |
10 import sys | 10 import sys |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 def RightHandSideLines(self): | 585 def RightHandSideLines(self): |
586 for line in self.lines: | 586 for line in self.lines: |
587 yield (presubmit.AffectedFile('bingo', 'M'), 1, line) | 587 yield (presubmit.AffectedFile('bingo', 'M'), 1, line) |
588 | 588 |
589 def testMembersChanged(self): | 589 def testMembersChanged(self): |
590 members = [ | 590 members = [ |
591 'CheckChangeHasBugField', 'CheckChangeHasNoTabs', | 591 'CheckChangeHasBugField', 'CheckChangeHasNoTabs', |
592 'CheckChangeHasQaField', 'CheckChangeHasTestedField', | 592 'CheckChangeHasQaField', 'CheckChangeHasTestedField', |
593 'CheckChangeHasTestField', 'CheckDoNotSubmit', | 593 'CheckChangeHasTestField', 'CheckDoNotSubmit', |
594 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', | 594 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', |
595 'CheckLongLines', 'CheckTreeIsOpen', | 595 'CheckLongLines', 'CheckTreeIsOpen', 'RunPythonUnitTests', |
596 ] | 596 ] |
597 # If this test fails, you should add the relevant test. | 597 # If this test fails, you should add the relevant test. |
598 self.compareMembers(presubmit_canned_checks, members) | 598 self.compareMembers(presubmit_canned_checks, members) |
599 | 599 |
600 def testCannedCheckChangeHasBugField(self): | 600 def testCannedCheckChangeHasBugField(self): |
601 change = self.MakeBasicChange('foo', | 601 change = self.MakeBasicChange('foo', |
602 'Foo\nBUG=1234') | 602 'Foo\nBUG=1234') |
603 api = presubmit.InputApi(change, './PRESUBMIT.py') | 603 api = presubmit.InputApi(change, './PRESUBMIT.py') |
604 self.failIf(presubmit_canned_checks.CheckChangeHasBugField( | 604 self.failIf(presubmit_canned_checks.CheckChangeHasBugField( |
605 api, presubmit.OutputApi)) | 605 api, presubmit.OutputApi)) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 )) | 686 )) |
687 | 687 |
688 def testCannedCheckTreeIsOpen(self): | 688 def testCannedCheckTreeIsOpen(self): |
689 self.failIf(presubmit_canned_checks.CheckTreeIsOpen( | 689 self.failIf(presubmit_canned_checks.CheckTreeIsOpen( |
690 self.MockInputApi(), presubmit.OutputApi, url='url_to_open', closed='0' | 690 self.MockInputApi(), presubmit.OutputApi, url='url_to_open', closed='0' |
691 )) | 691 )) |
692 self.failUnless(presubmit_canned_checks.CheckTreeIsOpen( | 692 self.failUnless(presubmit_canned_checks.CheckTreeIsOpen( |
693 self.MockInputApi(), presubmit.OutputApi, url='url_to_closed', closed='0' | 693 self.MockInputApi(), presubmit.OutputApi, url='url_to_closed', closed='0' |
694 )) | 694 )) |
695 | 695 |
| 696 def RunPythonUnitTests(self): |
| 697 # TODO(maruel): Add real tests. |
| 698 self.failIf(presubmit_canned_checks.RunPythonUnitTests( |
| 699 self.MockInputApi(), |
| 700 presubmit.OutputApi, [])) |
| 701 self.failUnless(presubmit_canned_checks.RunPythonUnitTests( |
| 702 self.MockInputApi(), |
| 703 presubmit.OutputApi, ['non_existent_module'])) |
696 | 704 |
697 if __name__ == '__main__': | 705 if __name__ == '__main__': |
698 unittest.main() | 706 unittest.main() |
OLD | NEW |