Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 """Chromium presubmit script to check that BadMessage enums in histograms.xml | 5 """Chromium presubmit script to check that BadMessage enums in histograms.xml |
| 6 match the corresponding bad_message.h file. | 6 match the corresponding bad_message.h file. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 def CheckChangeOnCommit(input_api, output_api): | |
| 10 return _CommonChecks(input_api, output_api) | |
| 11 | |
| 12 def CheckChangeOnUpload(input_api, output_api): | |
| 13 return _CommonChecks(input_api, output_api) | |
| 14 | |
|
Łukasz Anforowicz
2017/04/26 22:20:54
I don't understand why we have separate CheckChang
| |
| 9 def _RunHistogramChecks(input_api, output_api, histogram_name): | 15 def _RunHistogramChecks(input_api, output_api, histogram_name): |
| 10 try: | 16 try: |
| 11 # Setup sys.path so that we can call histrogram code | 17 # Setup sys.path so that we can call histrogram code |
| 12 import sys | 18 import sys |
| 13 original_sys_path = sys.path | 19 original_sys_path = sys.path |
| 14 sys.path = sys.path + [input_api.os_path.join( | 20 sys.path = sys.path + [input_api.os_path.join( |
| 15 input_api.change.RepositoryRoot(), | 21 input_api.change.RepositoryRoot(), |
| 16 'tools', 'metrics', 'histograms')] | 22 'tools', 'metrics', 'histograms')] |
| 17 | 23 |
| 18 import presubmit_bad_message_reasons | 24 import presubmit_bad_message_reasons |
| 19 return presubmit_bad_message_reasons.PrecheckBadMessage(input_api, | 25 return presubmit_bad_message_reasons.PrecheckBadMessage(input_api, |
| 20 output_api, histogram_name) | 26 output_api, histogram_name) |
| 21 except Exception as e: | 27 except Exception as e: |
| 22 return [output_api.PresubmitError("Error verifying histogram (%s)." | 28 return [output_api.PresubmitError("Error verifying histogram (%s)." |
| 23 % str(e))] | 29 % str(e))] |
| 24 finally: | 30 finally: |
| 25 sys.path = original_sys_path | 31 sys.path = original_sys_path |
| 26 | 32 |
| 27 def CheckChangeOnUpload(input_api, output_api): | 33 def _CommonChecks(input_api, output_api): |
| 28 return _RunHistogramChecks(input_api, output_api, "BadMessageReasonContent") | 34 return _RunHistogramChecks(input_api, output_api, "BadMessageReasonContent") |
| OLD | NEW |