Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Blink frame presubmit script | 5 """Blink frame presubmit script |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 source_path = '' | 67 source_path = '' |
| 68 for f in input_api.AffectedFiles(): | 68 for f in input_api.AffectedFiles(): |
| 69 if f.LocalPath().endswith('UseCounter.h'): | 69 if f.LocalPath().endswith('UseCounter.h'): |
| 70 source_path = f.LocalPath() | 70 source_path = f.LocalPath() |
| 71 break | 71 break |
| 72 else: | 72 else: |
| 73 return [] | 73 return [] |
| 74 | 74 |
| 75 start_marker = '^enum Feature : uint32_t {' | 75 start_marker = '^enum Feature : uint32_t {' |
| 76 end_marker = '^kNumberOfFeatures' | 76 end_marker = '^kNumberOfFeatures' |
| 77 should_update_histogram, duplicated_values = update_histogram_enum.Histogram NeedsUpdate( | 77 try: |
| 78 histogram_enum_name='FeatureObserver', | 78 if update_histogram_enum.HistogramNeedsUpdate( |
| 79 source_enum_path=source_path, | 79 histogram_enum_name='FeatureObserver', |
| 80 start_marker=start_marker, | 80 source_enum_path=source_path, |
| 81 end_marker=end_marker, | 81 start_marker=start_marker, |
| 82 strip_k_prefix=True) | 82 end_marker=end_marker, |
| 83 if duplicated_values: | 83 strip_k_prefix=True): |
| 84 return [output_api.PresubmitPromptWarning( | |
| 85 'UseCounter::Feature has been updated and the UMA mapping needs' | |
| 86 'to be regenerated. Please run ' | |
| 87 'update_use_counter_feature_enum.py in ' | |
| 88 'src/tools/metrics/histograms/ to update the mapping.', | |
| 89 items=[source_path])] | |
| 90 except Exception as duplicated_value: # pylint: disable=W0703 | |
|
Ilya Sherman
2017/04/21 22:51:40
Please catch only the specific type of exception t
| |
| 84 return [output_api.PresubmitPromptWarning( | 91 return [output_api.PresubmitPromptWarning( |
| 85 'UseCounter::Feature has been updated and there exists duplicated ' | 92 'UseCounter::Feature has been updated and there exists duplicated ' |
| 86 'values between (%s) and (%s)' % duplicated_values, | 93 'values between (%s) and (%s)' % duplicated_value.args, |
| 87 items=[source_path])] | |
| 88 if should_update_histogram: | |
| 89 return [output_api.PresubmitPromptWarning( | |
| 90 'UseCounter::Feature has been updated and the UMA mapping needs to ' | |
| 91 'be regenerated. Please run update_use_counter_feature_enum.py in ' | |
| 92 'src/tools/metrics/histograms/ to update the mapping.', | |
| 93 items=[source_path])] | 94 items=[source_path])] |
| 94 | 95 |
| 95 return [] | 96 return [] |
| 96 | 97 |
| 97 | 98 |
| 98 def CheckChangeOnUpload(input_api, output_api): | 99 def CheckChangeOnUpload(input_api, output_api): |
| 99 results = [] | 100 results = [] |
| 100 results.extend(_RunUseCounterChecks(input_api, output_api)) | 101 results.extend(_RunUseCounterChecks(input_api, output_api)) |
| 101 results.extend(_RunUmaHistogramChecks(input_api, output_api)) | 102 results.extend(_RunUmaHistogramChecks(input_api, output_api)) |
| 102 return results | 103 return results |
| 103 | 104 |
| 104 | 105 |
| 105 def CheckChangeOnCommit(input_api, output_api): | 106 def CheckChangeOnCommit(input_api, output_api): |
| 106 results = [] | 107 results = [] |
| 107 results.extend(_RunUseCounterChecks(input_api, output_api)) | 108 results.extend(_RunUseCounterChecks(input_api, output_api)) |
| 108 results.extend(_RunUmaHistogramChecks(input_api, output_api)) | 109 results.extend(_RunUmaHistogramChecks(input_api, output_api)) |
| 109 return results | 110 return results |
| OLD | NEW |