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 StringIO | 8 import StringIO |
9 | 9 |
10 import presubmit_support as presubmit | 10 import presubmit_support as presubmit |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 def MockAbsPath(f): | 42 def MockAbsPath(f): |
43 return f | 43 return f |
44 def MockChdir(f): | 44 def MockChdir(f): |
45 return None | 45 return None |
46 # SuperMoxTestBase already mock these but simplify our life. | 46 # SuperMoxTestBase already mock these but simplify our life. |
47 presubmit.os.path.abspath = MockAbsPath | 47 presubmit.os.path.abspath = MockAbsPath |
48 presubmit.os.getcwd = self.RootDir | 48 presubmit.os.getcwd = self.RootDir |
49 presubmit.os.chdir = MockChdir | 49 presubmit.os.chdir = MockChdir |
50 self.mox.StubOutWithMock(presubmit.scm.SVN, 'CaptureInfo') | 50 self.mox.StubOutWithMock(presubmit.scm.SVN, 'CaptureInfo') |
51 self.mox.StubOutWithMock(presubmit.scm.SVN, 'GetFileProperty') | 51 self.mox.StubOutWithMock(presubmit.scm.SVN, 'GetFileProperty') |
52 # TODO(maruel): Err, small duplication of code here. | |
53 self.mox.StubOutWithMock(presubmit.gcl, 'ReadFile') | |
54 self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileRead') | 52 self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileRead') |
| 53 self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileWrite') |
55 | 54 |
56 | 55 |
57 class PresubmitUnittest(PresubmitTestsBase): | 56 class PresubmitUnittest(PresubmitTestsBase): |
58 """General presubmit_support.py tests (excluding InputApi and OutputApi).""" | 57 """General presubmit_support.py tests (excluding InputApi and OutputApi).""" |
59 def testMembersChanged(self): | 58 def testMembersChanged(self): |
60 self.mox.ReplayAll() | 59 self.mox.ReplayAll() |
61 members = [ | 60 members = [ |
62 'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks', | 61 'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks', |
63 'GetTrySlavesExecuter', 'GitAffectedFile', 'GitChange', | 62 'GetTrySlavesExecuter', 'GitAffectedFile', 'GitChange', |
64 'InputApi', 'ListRelevantPresubmitFiles', 'Main', | 63 'InputApi', 'ListRelevantPresubmitFiles', 'Main', |
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 self.mox.ReplayAll() | 1461 self.mox.ReplayAll() |
1463 | 1462 |
1464 results = presubmit_canned_checks.RunPythonUnitTests( | 1463 results = presubmit_canned_checks.RunPythonUnitTests( |
1465 input_api, presubmit.OutputApi, ['test_module']) | 1464 input_api, presubmit.OutputApi, ['test_module']) |
1466 self.assertEquals(len(results), 0) | 1465 self.assertEquals(len(results), 0) |
1467 | 1466 |
1468 | 1467 |
1469 if __name__ == '__main__': | 1468 if __name__ == '__main__': |
1470 import unittest | 1469 import unittest |
1471 unittest.main() | 1470 unittest.main() |
OLD | NEW |