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

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

Issue 2797043002: Add a presubmit checker for duplicated enum values in UseCounter::Feature (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/frame/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/update_histogram_enum.py
diff --git a/tools/metrics/histograms/update_histogram_enum.py b/tools/metrics/histograms/update_histogram_enum.py
index db9037ff8bdf614e2976894fc59ae075ef72c814..36a0f4bfa6ab046824535fc4626615c1a5c90c5d 100644
--- a/tools/metrics/histograms/update_histogram_enum.py
+++ b/tools/metrics/histograms/update_histogram_enum.py
@@ -75,13 +75,16 @@ def ReadHistogramValues(filename, start_marker, end_marker):
label = m.group(1)
else:
continue
+ # If two enum constraints have the same value
Rick Byers 2017/04/05 15:26:39 s/constraints/constants/ ?
+ if enum_value in result:
+ return result, (result[enum_value], label)
result[enum_value] = label
enum_value += 1
else:
if START_REGEX.match(line):
inside_enum = True
enum_value = 0
- return result
+ return result, None
def CreateEnumItemNode(document, value, label):
@@ -180,12 +183,14 @@ def HistogramNeedsUpdate(histogram_enum_name, source_enum_path, start_marker,
end_marker: A regular expression that matches the end of the C++ enum.
"""
Log('Reading histogram enum definition from "{0}".'.format(source_enum_path))
- source_enum_values = ReadHistogramValues(source_enum_path, start_marker,
- end_marker)
+ source_enum_values, duplicated_values = ReadHistogramValues(
+ source_enum_path, start_marker, end_marker)
+ if duplicated_values is not None:
+ return False, duplicated_values
(xml, new_xml) = _GetOldAndUpdatedXml(histogram_enum_name, source_enum_values,
source_enum_path)
- return xml != new_xml
+ return xml != new_xml, None
def UpdateHistogramFromDict(histogram_enum_name, source_enum_values,
« no previous file with comments | « third_party/WebKit/Source/core/frame/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698