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

Side by Side 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: ws Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « extensions/browser/PRESUBMIT.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Check to see if the various BadMessage enums in histograms.xml need to be
6 updated. This can be called from a chromium PRESUBMIT.py to ensure updates to
7 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.
8 """
9
10 import update_histogram_enum
11
12 def PrecheckBadMessage(input_api, output_api, histogram_name):
13 source_path = ''
14
15 for f in input_api.AffectedFiles():
16 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
17 source_path = f.LocalPath()
18 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
19
20 # 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.
21 if source_path == '':
22 return []
23
24 START_MARKER='^enum (class )?BadMessageReason {'
25 END_MARKER='^BAD_MESSAGE_MAX'
26 if update_histogram_enum.HistogramNeedsUpdate(
27 histogram_enum_name=histogram_name,
28 source_enum_path=source_path,
29 start_marker=START_MARKER,
30 end_marker=END_MARKER):
31 return [output_api.PresubmitPromptWarning(
32 'bad_messages.h has been updated but histogram.xml does not '
33 'appear to be updated.\nPlease run:\n'
34 ' python tools/metrics/histograms/update_bad_message_reasons.py\n')]
35 return []
OLDNEW
« no previous file with comments | « extensions/browser/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698