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 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') 16 cmd = [input_api.python_executable, check_script] 17 try: 18 input_api.subprocess.check_output(cmd) 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 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 35