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
)]
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
)):
30 if not sys
.platform
.startswith('linux'):
32 sys
.path
.insert(0, input_api
.os_path
.join(
33 input_api
.PresubmitLocalPath(), 'tools'))
35 from check_chromevox
import CheckChromeVox
38 success
, output
= CheckChromeVox(paths
)
40 return [output_api
.PresubmitError(
41 'ChromeVox closure compilation failed',