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 messages = stream.getvalue().split('\n') | |
zra
2016/11/27 04:04:55
I don't remember exactly how the messages look, bu
kustermann
2016/11/30 21:40:32
The goal is not to prevent the "Continue (y/N)" li
| |
59 message = messages[0] if messages else 'Unknown formatting error.' | |
zra
2016/11/27 04:04:55
Did you see this happen? Instead of printing 'Unkn
kustermann
2016/11/30 21:40:32
Done - It was just a precaution, I'll let it throw
| |
60 return output_api.PresubmitError(message) | |
61 return presubmit_result | |
62 | |
63 results = input_api.canned_checks.CheckPatchFormatted(input_api, output_api) | |
64 return [convert_warning_to_error(r) for r in results] | |
53 | 65 |
54 | 66 |
55 def CheckChangeOnUpload(input_api, output_api): | 67 def CheckChangeOnUpload(input_api, output_api): |
56 return (RunLint(input_api, output_api) + | 68 return (RunLint(input_api, output_api) + |
57 CheckGn(input_api, output_api) + | 69 CheckGn(input_api, output_api) + |
58 CheckFormatted(input_api, output_api)) | 70 CheckFormatted(input_api, output_api)) |
59 | 71 |
60 | 72 |
61 def CheckChangeOnCommit(input_api, output_api): | 73 def CheckChangeOnCommit(input_api, output_api): |
62 return (RunLint(input_api, output_api) + | 74 return (RunLint(input_api, output_api) + |
63 CheckGn(input_api, output_api) + | 75 CheckGn(input_api, output_api) + |
64 CheckFormatted(input_api, output_api)) | 76 CheckFormatted(input_api, output_api)) |
OLD | NEW |