• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Chromium presubmit script to check that BadMessage enums in histograms.xml
6match the corresponding bad_message.h file.
7"""
8
9USE_PYTHON3 = True
10
11def _RunHistogramChecks(input_api, output_api, histogram_name):
12  try:
13    # Setup sys.path so that we can call histograms code.
14    import sys
15    original_sys_path = sys.path
16    sys.path = sys.path + [input_api.os_path.join(
17      input_api.change.RepositoryRoot(),
18      'tools', 'metrics', 'histograms')]
19
20    import presubmit_bad_message_reasons
21    return presubmit_bad_message_reasons.PrecheckBadMessage(input_api,
22      output_api, histogram_name)
23  except:
24    return [output_api.PresubmitError('Could not verify histogram!')]
25  finally:
26    sys.path = original_sys_path
27
28def CheckChangeOnUpload(input_api, output_api):
29  return _RunHistogramChecks(input_api, output_api, "BadMessageReasonNaCl")
30