xref: /aosp_15_r20/external/pdfium/public/PRESUBMIT.py (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1# Copyright 2017 The PDFium 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"""Presubmit script for pdfium.
6
7See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8for more details about the presubmit API built into depot_tools.
9"""
10
11USE_PYTHON3 = True
12
13
14def _CheckPublicHeaders(input_api, output_api):
15  """Checks that the public headers match the API tests."""
16  src_path = input_api.os_path.dirname(input_api.PresubmitLocalPath())
17  check_script = input_api.os_path.join(
18      src_path, 'testing' , 'tools' , 'api_check.py')
19  cmd = [input_api.python3_executable, check_script]
20  try:
21    input_api.subprocess.check_output(cmd)
22    return []
23  except input_api.subprocess.CalledProcessError as error:
24    return [output_api.PresubmitError('api_check.py failed:',
25                                      long_text=error.output)]
26
27
28def CheckChangeOnUpload(input_api, output_api):
29  results = []
30  results.extend(_CheckPublicHeaders(input_api, output_api))
31  return results
32
33
34def CheckChangeOnCommit(input_api, output_api):
35  results = []
36  results.extend(_CheckPublicHeaders(input_api, output_api))
37  return results
38