Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / chromevox / PRESUBMIT.py
blobb87797c1b34d8ad4b53c4527e52c224c75483ec8
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.
5 """Presubmit script for ChromeVox."""
7 def CheckChangeOnUpload(input_api, output_api):
8 paths = input_api.AbsoluteLocalPaths()
10 def ShouldCheckFile(path):
11 return path.endswith('.js') or path.endswith('.py')
13 def ScriptFilter(path):
14 return (path.endswith('check_chromevox.py') or
15 path.endswith('jscompilerwrapper.py') or
16 path.endswith('jsbundler.py'))
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 []
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
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 []