blob: 5081823e84ac93ed016071b2366f57d85aaf7eca [file] [log] [blame]
Lei Zhang9ccf0872017-12-19 18:50:15 +00001# Copyright 2017 The PDFium 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
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
11def _CheckPublicHeaders(input_api, output_api):
12 """Checks that the public headers match the API tests."""
13 src_path = input_api.os_path.dirname(input_api.PresubmitLocalPath())
14 check_script = input_api.os_path.join(
15 src_path, 'testing' , 'tools' , 'api_check.py')
Lei Zhang90ddbac2019-07-17 17:27:28 +000016 cmd = [input_api.python_executable, check_script]
Lei Zhang9ccf0872017-12-19 18:50:15 +000017 try:
Lei Zhang90ddbac2019-07-17 17:27:28 +000018 input_api.subprocess.check_output(cmd)
Lei Zhang9ccf0872017-12-19 18:50:15 +000019 return []
20 except input_api.subprocess.CalledProcessError as error:
21 return [output_api.PresubmitError('api_check.py failed:',
22 long_text=error.output)]
23
24
25def CheckChangeOnUpload(input_api, output_api):
26 results = []
27 results += _CheckPublicHeaders(input_api, output_api)
28 return results
29
30
31def CheckChangeOnCommit(input_api, output_api):
32 results = []
33 results += _CheckPublicHeaders(input_api, output_api)
34 return results