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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 self.mox.ReplayAll() | 743 self.mox.ReplayAll() |
744 | 744 |
745 self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 20) | 745 self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 20) |
746 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 9) | 746 self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 9) |
747 for item in files: | 747 for item in files: |
748 results = filter(input_api.FilterSourceFile, item[0]) | 748 results = filter(input_api.FilterSourceFile, item[0]) |
749 for i in range(len(results)): | 749 for i in range(len(results)): |
750 self.assertEquals(results[i].LocalPath(), | 750 self.assertEquals(results[i].LocalPath(), |
751 presubmit.normpath(item[1][i])) | 751 presubmit.normpath(item[1][i])) |
752 # Same number of expected results. | 752 # Same number of expected results. |
753 self.assertEquals(sorted([f.LocalPath() for f in results]), | 753 self.assertEquals(sorted([f.LocalPath().replace(presubmit.os.sep, '/') |
| 754 for f in results]), |
754 sorted(item[1])) | 755 sorted(item[1])) |
755 | 756 |
756 def testCustomFilter(self): | 757 def testCustomFilter(self): |
757 def FilterSourceFile(affected_file): | 758 def FilterSourceFile(affected_file): |
758 return 'a' in affected_file.LocalPath() | 759 return 'a' in affected_file.LocalPath() |
759 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee')] | 760 files = [('A', 'eeaee'), ('M', 'eeabee'), ('M', 'eebcee')] |
760 for (action, item) in files: | 761 for (action, item) in files: |
761 item = presubmit.os.path.join(self.fake_root_dir, item) | 762 item = presubmit.os.path.join(self.fake_root_dir, item) |
762 presubmit.os.path.exists(item).AndReturn(True) | 763 presubmit.os.path.exists(item).AndReturn(True) |
763 presubmit.os.path.isdir(item).AndReturn(False) | 764 presubmit.os.path.isdir(item).AndReturn(False) |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 results = presubmit_canned_checks.CheckBuildbotPendingBuilds( | 1604 results = presubmit_canned_checks.CheckBuildbotPendingBuilds( |
1604 input_api, presubmit.OutputApi, 'uurl', 2, ('foo')) | 1605 input_api, presubmit.OutputApi, 'uurl', 2, ('foo')) |
1605 self.assertEquals(len(results), 1) | 1606 self.assertEquals(len(results), 1) |
1606 self.assertEquals(results[0].__class__, | 1607 self.assertEquals(results[0].__class__, |
1607 presubmit.OutputApi.PresubmitNotifyResult) | 1608 presubmit.OutputApi.PresubmitNotifyResult) |
1608 | 1609 |
1609 | 1610 |
1610 if __name__ == '__main__': | 1611 if __name__ == '__main__': |
1611 import unittest | 1612 import unittest |
1612 unittest.main() | 1613 unittest.main() |
OLD | NEW |