Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: tools/metrics/histograms/presubmit_bad_message_reasons.py

Issue 2653273003: Add presubmit scripts to check histograms.xml if bad_message.h changes. (Closed)
Patch Set: address isherman comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« components/nacl/browser/PRESUBMIT.py ('K') | « extensions/browser/PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..909dc74adab8629f8c43cfa2deb65e25b20ea690
--- /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_message.h also include the generated changes to histograms.xml
+"""
+
+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'):
+ source_path = f.LocalPath()
+ break
+
+ # If bad_message.h wasn't changed, then there is nothing to check.
Ilya Sherman 2017/02/01 00:35:13 nit: It would be great to clarify in this document
dougt 2017/02/01 02:49:06 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 '
brettw 2017/02/01 00:28:22 I'm not an expert at Python style (so if you know
dougt 2017/02/01 02:49:06 Done. The style is to indent 4 spaces (or align wh
+ 'appear to be updated.\nPlease run:\n'
+ ' python tools/metrics/histograms/update_bad_message_reasons.py\n')]
+ return []
« components/nacl/browser/PRESUBMIT.py ('K') | « extensions/browser/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698