| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 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 top-level Chromium presubmit script. | 6 """Unit tests for top-level Chromium presubmit script. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 | 9 |
| 10 import os | 10 import os |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 def testLocalChecks(self): | 55 def testLocalChecks(self): |
| 56 api = MockInputApi() | 56 api = MockInputApi() |
| 57 api.affected_files = [ | 57 api.affected_files = [ |
| 58 MockAffectedFile('foo/blat/yoo.notsource'), | 58 MockAffectedFile('foo/blat/yoo.notsource'), |
| 59 MockAffectedFile('third_party/blat/source.cc'), | 59 MockAffectedFile('third_party/blat/source.cc'), |
| 60 MockAffectedFile('foo/blat/source.h'), | 60 MockAffectedFile('foo/blat/source.h'), |
| 61 MockAffectedFile('foo/blat/source.mm'), | 61 MockAffectedFile('foo/blat/source.mm'), |
| 62 MockAffectedFile('foo/blat/source.py'), | 62 MockAffectedFile('foo/blat/source.py'), |
| 63 ] | 63 ] |
| 64 self.file_contents = 'file with \n\terror\nhere\r\nyes there' | 64 self.file_contents = 'file with \n\terror\nhere\r\nyes there' |
| 65 # 3 source files, 2 errors by file + 1 global CR error. | 65 # 3 source files, 2 errors by file + 1 global CR + 1 global EOF error. |
| 66 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 7) | 66 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 8) |
| 67 | 67 |
| 68 self.file_contents = 'file\twith\ttabs' | 68 self.file_contents = 'file\twith\ttabs\n' |
| 69 # 3 source files, 1 error by file. | 69 # 3 source files, 1 error by file. |
| 70 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 3) | 70 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 3) |
| 71 | 71 |
| 72 self.file_contents = 'file\rusing\rCRs' | 72 self.file_contents = 'file\rusing\rCRs\n' |
| 73 # One global CR error. | 73 # One global CR error. |
| 74 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 1) | 74 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 1) |
| 75 self.failUnless( | 75 self.failUnless( |
| 76 len(PRESUBMIT.LocalChecks(api, MockOutputApi)[0].items) == 3) | 76 len(PRESUBMIT.LocalChecks(api, MockOutputApi)[0].items) == 3) |
| 77 | 77 |
| 78 self.file_contents = 'both\ttabs and\r\nCRLF' | 78 self.file_contents = 'both\ttabs and\r\nCRLF\n' |
| 79 # 3 source files, 1 error by file + 1 global CR error. | 79 # 3 source files, 1 error by file + 1 global CR error. |
| 80 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 4) | 80 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 4) |
| 81 | 81 |
| 82 self.file_contents = 'file with\nzero \\t errors \\r\\n' | 82 self.file_contents = 'file with\nzero \\t errors \\r\\n\n' |
| 83 self.failIf(PRESUBMIT.LocalChecks(api, MockOutputApi)) | 83 self.failIf(PRESUBMIT.LocalChecks(api, MockOutputApi)) |
| 84 | 84 |
| 85 | 85 |
| 86 if __name__ == '__main__': | 86 if __name__ == '__main__': |
| 87 unittest.main() | 87 unittest.main() |
| OLD | NEW |