PRESUBMIT.py revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)# Copyright 2014 The Chromium Authors. All rights reserved. 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)# found in the LICENSE file. 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)"""Presubmit script for ChromeVox.""" 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)def CheckChangeOnUpload(input_api, output_api): 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) paths = input_api.AbsoluteLocalPaths() 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) def FileFilter(path): 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return (path.endswith('check_chromevox.py') or 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) path.endswith('jscompilerwrapper.py') or 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) path.endswith('jsbundler.py')) 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) # If changing what the presubmit script uses, run the check on all 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) # scripts. Otherwise, let CheckChromeVox figure out what scripts to 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) # compile, if any, based on the changed paths. 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if any((FileFilter(p) for p in paths)): 170529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch paths = None 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) import sys 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if not sys.platform.startswith('linux'): 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return [] 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) sys.path.insert(0, input_api.os_path.join( 220529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch input_api.PresubmitLocalPath(), 'tools')) 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) try: 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) from check_chromevox import CheckChromeVox 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) finally: 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) sys.path.pop(0) 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) success, output = CheckChromeVox(paths) 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if not success: 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return [output_api.PresubmitError( 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 'ChromeVox closure compilation failed', 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) long_text=output)] 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return [] 33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)