Chromium Code Reviews| Index: tools/metrics/histograms/presubmit_bad_message_reasons.py |
| diff --git a/tools/metrics/histograms/presubmit_bad_message_reasons.py b/tools/metrics/histograms/presubmit_bad_message_reasons.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ef8842390621977e9d85da0ef11eb8fe7adac0ce |
| --- /dev/null |
| +++ b/tools/metrics/histograms/presubmit_bad_message_reasons.py |
| @@ -0,0 +1,35 @@ |
| +# Copyright 2017 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Check to see if the various BadMessage enums in histograms.xml need to be |
| +updated. This can be called from a chromium PRESUBMIT.py to ensure updates to |
| +bad_messages.h also include the generated changes to histograms.xml |
|
Ilya Sherman
2017/01/27 23:35:13
nit: bad_messages or bad_message, as typed below?
dougt
2017/01/28 00:58:11
Done.
|
| +""" |
| + |
| +import update_histogram_enum |
| + |
| +def PrecheckBadMessage(input_api, output_api, histogram_name): |
| + source_path = '' |
| + |
| + for f in input_api.AffectedFiles(): |
| + if f.LocalPath().endswith('bad_message.h'): |
|
dgozman
2017/01/27 23:19:32
Let's pass this as a parameter.
dougt
2017/01/27 23:25:47
Acknowledged. It's always bad_message.h at this po
|
| + source_path = f.LocalPath() |
| + break |
|
Ilya Sherman
2017/01/27 23:35:13
There are multiple bad_message files in the reposi
dougt
2017/01/28 00:58:11
You will get one warning that asks you to run 'pyt
Ilya Sherman
2017/01/28 02:53:35
Why are you guaranteed to get this warning? It lo
|
| + |
| + # If bad message wasn't change, then there is nothing to check. |
|
Ilya Sherman
2017/01/27 23:35:13
nit: s/bad message/bad_message.h
Ilya Sherman
2017/01/27 23:35:13
nit: s/change/changed
dougt
2017/01/28 00:58:11
Done.
|
| + if source_path == '': |
| + return [] |
| + |
| + START_MARKER='^enum (class )?BadMessageReason {' |
| + END_MARKER='^BAD_MESSAGE_MAX' |
| + if update_histogram_enum.HistogramNeedsUpdate( |
| + histogram_enum_name=histogram_name, |
| + source_enum_path=source_path, |
| + start_marker=START_MARKER, |
| + end_marker=END_MARKER): |
| + return [output_api.PresubmitPromptWarning( |
| + 'bad_messages.h has been updated but histogram.xml does not ' |
| + 'appear to be updated.\nPlease run:\n' |
| + ' python tools/metrics/histograms/update_bad_message_reasons.py\n')] |
| + return [] |