PRESUBMIT.py revision 6e8cce623b6e4fe0c9e4af605d675dd9d0338c38
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 7def CheckChangeOnUpload(input_api, output_api): 8 paths = input_api.AbsoluteLocalPaths() 9 10 def ShouldCheckFile(path): 11 return path.endswith('.js') or path.endswith('.py') 12 13 def ScriptFilter(path): 14 return (path.endswith('check_chromevox.py') or 15 path.endswith('jscompilerwrapper.py') or 16 path.endswith('jsbundler.py')) 17 18 # Only care about changes to JS files or the scripts that check them. 19 paths = [p for p in paths if ShouldCheckFile(p)] 20 if not paths: 21 return [] 22 23 # If changing what the presubmit script uses, run the check on all 24 # scripts. Otherwise, let CheckChromeVox figure out what scripts to 25 # compile, if any, based on the changed paths. 26 if any((ScriptFilter(p) for p in paths)): 27 paths = None 28 29 import sys 30 if not sys.platform.startswith('linux'): 31 return [] 32 sys.path.insert(0, input_api.os_path.join( 33 input_api.PresubmitLocalPath(), 'tools')) 34 try: 35 from check_chromevox import CheckChromeVox 36 finally: 37 sys.path.pop(0) 38 success, output = CheckChromeVox(paths) 39 if not success: 40 return [output_api.PresubmitError( 41 'ChromeVox closure compilation failed', 42 long_text=output)] 43 return [] 44