PRESUBMIT.py 1021 B

1234567891011121314151617181920212223242526272829
  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. """Chromium presubmit script to check that BadMessage enums in histograms.xml
  5. match the corresponding bad_message.h file.
  6. """
  7. USE_PYTHON3 = True
  8. def _RunHistogramChecks(input_api, output_api, histogram_name):
  9. try:
  10. # Setup sys.path so that we can call histograms code.
  11. import sys
  12. original_sys_path = sys.path
  13. sys.path = sys.path + [input_api.os_path.join(
  14. input_api.change.RepositoryRoot(),
  15. 'tools', 'metrics', 'histograms')]
  16. import presubmit_bad_message_reasons
  17. return presubmit_bad_message_reasons.PrecheckBadMessage(input_api,
  18. output_api, histogram_name)
  19. except:
  20. return [output_api.PresubmitError('Could not verify histogram!')]
  21. finally:
  22. sys.path = original_sys_path
  23. def CheckChangeOnUpload(input_api, output_api):
  24. return _RunHistogramChecks(input_api, output_api, "BadMessageReasonGuestView")