1 # Copyright 2014 The Chromium 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 ChromeVox.""" 6 7 def CheckChangeOnUpload(input_api, output_api): 8 paths = input_api.AbsoluteLocalPaths() 9 def FileFilter(path): 10 return (path.endswith('check_chromevox.py') or 11 path.endswith('jscompilerwrapper.py') or 12 path.endswith('jsbundler.py')) 13 # If changing what the presubmit script uses, run the check on all 14 # scripts. Otherwise, let CheckChromeVox figure out what scripts to 15 # compile, if any, based on the changed paths. 16 if any((FileFilter(p) for p in paths)): 17 paths = None 18 import sys 19 if not sys.platform.startswith('linux'): 20 return [] 21 sys.path.insert(0, input_api.os_path.join( 22 input_api.PresubmitLocalPath(), 'tools')) 23 try: 24 from check_chromevox import CheckChromeVox 25 finally: 26 sys.path.pop(0) 27 success, output = CheckChromeVox(paths) 28 if not success: 29 return [output_api.PresubmitError( 30 'ChromeVox closure compilation failed', 31 long_text=output)] 32 return [] 33