
This CL fixes presubmit_scheme_histograms.py and presubmit_bad_message_reasons.py which after r462591 would always report presubmit errors (because it started returning a tuple from HistogramNeedsUpdate which always coerces to True in the broken presubmit scripts). After r462591 HistogramNeedsUpdate effectively checks all histogram-enum-related presubmits (both for updating histograms.xml and for detecting duplicate values). Therefore the current CL renames this function to CheckPresubmitErrors and makes it return a presubmit error (rather than a tuple of (needs_updating, duplicates)). This refactoring has a nice side benefit - after this CL, all presubmits going through CheckPresubmitErrors will check for duplicate values (r462591 only added this check for UseCounter histograms). This CL also tweaks content/browser/PRESUBMIT.py so that it applies *both* to upload-time and commit-time checks (without this change |git cl presubmit| would not hit the checks related to content/browser/bad_message.h - they would only be hit when running |git cl presubmit --upload|). Manual testing done: - Make changes in content/browser/bad_message.h, chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc, third_party/WebKit/Source/code/frame - Run git cl presubmit and verify that the presubmit checks detect 1) duplicates and 2) the need to update histograms.xml BUG=577772 TEST=See "Manual testing done" above. TBR=sky@chromium.org, jochen@chromium.org, rdevlin.cronin@chromium.org Review-Url: https://codereview.chromium.org/2841823007 Cr-Commit-Position: refs/heads/master@{#468003}
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# 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.
|
|
|
|
"""Chromium presubmit script to check that BadMessage enums in histograms.xml
|
|
match the corresponding bad_message.h file.
|
|
"""
|
|
|
|
def CheckChangeOnCommit(input_api, output_api):
|
|
return _CommonChecks(input_api, output_api)
|
|
|
|
def CheckChangeOnUpload(input_api, output_api):
|
|
return _CommonChecks(input_api, output_api)
|
|
|
|
def _RunHistogramChecks(input_api, output_api, histogram_name):
|
|
try:
|
|
# Setup sys.path so that we can call histograms code.
|
|
import sys
|
|
original_sys_path = sys.path
|
|
sys.path = sys.path + [input_api.os_path.join(
|
|
input_api.change.RepositoryRoot(),
|
|
'tools', 'metrics', 'histograms')]
|
|
|
|
import presubmit_bad_message_reasons
|
|
return presubmit_bad_message_reasons.PrecheckBadMessage(input_api,
|
|
output_api, histogram_name)
|
|
except Exception as e:
|
|
return [output_api.PresubmitError("Error verifying histogram (%s)."
|
|
% str(e))]
|
|
finally:
|
|
sys.path = original_sys_path
|
|
|
|
def _CommonChecks(input_api, output_api):
|
|
return _RunHistogramChecks(input_api, output_api, "BadMessageReasonContent")
|