Lei Zhang | 9ccf087 | 2017-12-19 18:50:15 +0000 | [diff] [blame] | 1 | # 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 | |
| 7 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 | for more details about the presubmit API built into depot_tools. |
| 9 | """ |
| 10 | |
| 11 | def _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 Zhang | 90ddbac | 2019-07-17 17:27:28 +0000 | [diff] [blame] | 16 | cmd = [input_api.python_executable, check_script] |
Lei Zhang | 9ccf087 | 2017-12-19 18:50:15 +0000 | [diff] [blame] | 17 | try: |
Lei Zhang | 90ddbac | 2019-07-17 17:27:28 +0000 | [diff] [blame] | 18 | input_api.subprocess.check_output(cmd) |
Lei Zhang | 9ccf087 | 2017-12-19 18:50:15 +0000 | [diff] [blame] | 19 | 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 | |
| 25 | def CheckChangeOnUpload(input_api, output_api): |
| 26 | results = [] |
| 27 | results += _CheckPublicHeaders(input_api, output_api) |
| 28 | return results |
| 29 | |
| 30 | |
| 31 | def CheckChangeOnCommit(input_api, output_api): |
| 32 | results = [] |
| 33 | results += _CheckPublicHeaders(input_api, output_api) |
| 34 | return results |