1*3ac0a46fSAndroid Build Coastguard Worker# Copyright 2017 The PDFium Authors 2*3ac0a46fSAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 3*3ac0a46fSAndroid Build Coastguard Worker# found in the LICENSE file. 4*3ac0a46fSAndroid Build Coastguard Worker 5*3ac0a46fSAndroid Build Coastguard Worker"""Presubmit script for pdfium. 6*3ac0a46fSAndroid Build Coastguard Worker 7*3ac0a46fSAndroid Build Coastguard WorkerSee http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 8*3ac0a46fSAndroid Build Coastguard Workerfor more details about the presubmit API built into depot_tools. 9*3ac0a46fSAndroid Build Coastguard Worker""" 10*3ac0a46fSAndroid Build Coastguard Worker 11*3ac0a46fSAndroid Build Coastguard WorkerUSE_PYTHON3 = True 12*3ac0a46fSAndroid Build Coastguard Worker 13*3ac0a46fSAndroid Build Coastguard Worker 14*3ac0a46fSAndroid Build Coastguard Workerdef _CheckPublicHeaders(input_api, output_api): 15*3ac0a46fSAndroid Build Coastguard Worker """Checks that the public headers match the API tests.""" 16*3ac0a46fSAndroid Build Coastguard Worker src_path = input_api.os_path.dirname(input_api.PresubmitLocalPath()) 17*3ac0a46fSAndroid Build Coastguard Worker check_script = input_api.os_path.join( 18*3ac0a46fSAndroid Build Coastguard Worker src_path, 'testing' , 'tools' , 'api_check.py') 19*3ac0a46fSAndroid Build Coastguard Worker cmd = [input_api.python3_executable, check_script] 20*3ac0a46fSAndroid Build Coastguard Worker try: 21*3ac0a46fSAndroid Build Coastguard Worker input_api.subprocess.check_output(cmd) 22*3ac0a46fSAndroid Build Coastguard Worker return [] 23*3ac0a46fSAndroid Build Coastguard Worker except input_api.subprocess.CalledProcessError as error: 24*3ac0a46fSAndroid Build Coastguard Worker return [output_api.PresubmitError('api_check.py failed:', 25*3ac0a46fSAndroid Build Coastguard Worker long_text=error.output)] 26*3ac0a46fSAndroid Build Coastguard Worker 27*3ac0a46fSAndroid Build Coastguard Worker 28*3ac0a46fSAndroid Build Coastguard Workerdef CheckChangeOnUpload(input_api, output_api): 29*3ac0a46fSAndroid Build Coastguard Worker results = [] 30*3ac0a46fSAndroid Build Coastguard Worker results.extend(_CheckPublicHeaders(input_api, output_api)) 31*3ac0a46fSAndroid Build Coastguard Worker return results 32*3ac0a46fSAndroid Build Coastguard Worker 33*3ac0a46fSAndroid Build Coastguard Worker 34*3ac0a46fSAndroid Build Coastguard Workerdef CheckChangeOnCommit(input_api, output_api): 35*3ac0a46fSAndroid Build Coastguard Worker results = [] 36*3ac0a46fSAndroid Build Coastguard Worker results.extend(_CheckPublicHeaders(input_api, output_api)) 37*3ac0a46fSAndroid Build Coastguard Worker return results 38