OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 import glob | 6 import glob |
7 import json | 7 import json |
8 import os | 8 import os |
9 import re | 9 import re |
10 import subprocess | 10 import subprocess |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 '=======', | 263 '=======', |
264 ' ScopedTempDir temp_dir_;', | 264 ' ScopedTempDir temp_dir_;', |
265 '>>>>>>> master'] | 265 '>>>>>>> master'] |
266 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( | 266 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( |
267 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) | 267 MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) |
268 self.assertEqual(3, len(errors)) | 268 self.assertEqual(3, len(errors)) |
269 self.assertTrue('1' in errors[0]) | 269 self.assertTrue('1' in errors[0]) |
270 self.assertTrue('3' in errors[1]) | 270 self.assertTrue('3' in errors[1]) |
271 self.assertTrue('5' in errors[2]) | 271 self.assertTrue('5' in errors[2]) |
272 | 272 |
| 273 def testIgnoresReadmes(self): |
| 274 lines = ['A First Level Header', |
| 275 '====================', |
| 276 '', |
| 277 'A Second Level Header', |
| 278 '---------------------'] |
| 279 errors = PRESUBMIT._CheckForVersionControlConflictsInFile( |
| 280 MockInputApi(), MockFile('some/polymer/README.md', lines)) |
| 281 self.assertEqual(0, len(errors)) |
| 282 |
273 class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase): | 283 class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase): |
274 def testTypicalCorrectlyMatchedChange(self): | 284 def testTypicalCorrectlyMatchedChange(self): |
275 diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)'] | 285 diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)'] |
276 diff_xml = ['<histogram name="Bla.Foo.Dummy"> </histogram>'] | 286 diff_xml = ['<histogram name="Bla.Foo.Dummy"> </histogram>'] |
277 mock_input_api = MockInputApi() | 287 mock_input_api = MockInputApi() |
278 mock_input_api.files = [ | 288 mock_input_api.files = [ |
279 MockFile('some/path/foo.cc', diff_cc), | 289 MockFile('some/path/foo.cc', diff_cc), |
280 MockFile('tools/metrics/histograms/histograms.xml', diff_xml), | 290 MockFile('tools/metrics/histograms/histograms.xml', diff_xml), |
281 ] | 291 ] |
282 warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api, | 292 warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api, |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 mock_input_api, mock_output_api) | 855 mock_input_api, mock_output_api) |
846 | 856 |
847 self.assertEqual(1, len(warnings)) | 857 self.assertEqual(1, len(warnings)) |
848 self.assertEqual(2, len(warnings[0].items)) | 858 self.assertEqual(2, len(warnings[0].items)) |
849 self.assertTrue('HasAndroidLog.java' in warnings[0].items[0]) | 859 self.assertTrue('HasAndroidLog.java' in warnings[0].items[0]) |
850 self.assertTrue('HasExplicitLog.java' in warnings[0].items[1]) | 860 self.assertTrue('HasExplicitLog.java' in warnings[0].items[1]) |
851 | 861 |
852 | 862 |
853 if __name__ == '__main__': | 863 if __name__ == '__main__': |
854 unittest.main() | 864 unittest.main() |
OLD | NEW |