OLD | NEW |
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 import cpplint | 6 import cpplint |
7 import re | 7 import re |
| 8 import StringIO |
8 | 9 |
9 # memcpy does not handle overlapping memory regions. Even though this | 10 # memcpy does not handle overlapping memory regions. Even though this |
10 # is well documented it seems to be used in error quite often. To avoid | 11 # is well documented it seems to be used in error quite often. To avoid |
11 # problems we disallow the direct use of memcpy. The exceptions are in | 12 # problems we disallow the direct use of memcpy. The exceptions are in |
12 # third-party code and in platform/globals.h which uses it to implement | 13 # third-party code and in platform/globals.h which uses it to implement |
13 # bit_cast and bit_copy. | 14 # bit_cast and bit_copy. |
14 def CheckMemcpy(filename): | 15 def CheckMemcpy(filename): |
15 if filename.endswith(os.path.join('platform', 'globals.h')) or \ | 16 if filename.endswith(os.path.join('platform', 'globals.h')) or \ |
16 filename.find('third_party') != -1: | 17 filename.find('third_party') != -1: |
17 return 0 | 18 return 0 |
(...skipping 24 matching lines...) Expand all Loading... |
42 if cpplint._cpplint_state.error_count > 0 or memcpy_match_count > 0: | 43 if cpplint._cpplint_state.error_count > 0 or memcpy_match_count > 0: |
43 result = [output_api.PresubmitError('Failed cpplint check.')] | 44 result = [output_api.PresubmitError('Failed cpplint check.')] |
44 return result | 45 return result |
45 | 46 |
46 | 47 |
47 def CheckGn(input_api, output_api): | 48 def CheckGn(input_api, output_api): |
48 return input_api.canned_checks.CheckGNFormatted(input_api, output_api) | 49 return input_api.canned_checks.CheckGNFormatted(input_api, output_api) |
49 | 50 |
50 | 51 |
51 def CheckFormatted(input_api, output_api): | 52 def CheckFormatted(input_api, output_api): |
52 return input_api.canned_checks.CheckPatchFormatted(input_api, output_api) | 53 def convert_warning_to_error(presubmit_result): |
| 54 if not presubmit_result.fatal: |
| 55 # Convert this warning to an error. |
| 56 stream = StringIO.StringIO() |
| 57 presubmit_result.handle(stream) |
| 58 message = stream.getvalue() |
| 59 return output_api.PresubmitError(message) |
| 60 return presubmit_result |
| 61 |
| 62 results = input_api.canned_checks.CheckPatchFormatted(input_api, output_api) |
| 63 return [convert_warning_to_error(r) for r in results] |
53 | 64 |
54 | 65 |
55 def CheckChangeOnUpload(input_api, output_api): | 66 def CheckChangeOnUpload(input_api, output_api): |
56 return (RunLint(input_api, output_api) + | 67 return (RunLint(input_api, output_api) + |
57 CheckGn(input_api, output_api) + | 68 CheckGn(input_api, output_api) + |
58 CheckFormatted(input_api, output_api)) | 69 CheckFormatted(input_api, output_api)) |
59 | 70 |
60 | 71 |
61 def CheckChangeOnCommit(input_api, output_api): | 72 def CheckChangeOnCommit(input_api, output_api): |
62 return (RunLint(input_api, output_api) + | 73 return (RunLint(input_api, output_api) + |
63 CheckGn(input_api, output_api) + | 74 CheckGn(input_api, output_api) + |
64 CheckFormatted(input_api, output_api)) | 75 CheckFormatted(input_api, output_api)) |
OLD | NEW |