Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / PRESUBMIT.py
1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 #     * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 #     * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 #     * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 """Blink bindings presubmit script
30
31 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
32 for more details about the presubmit API built into gcl.
33 """
34
35 # Changes to v8/ do not change generated code or tests, so exclude from
36 # _RunBindingsTests
37 BLACK_LIST = (r'.*\bv8[\\\/].*',)
38
39 def _RunBindingsTests(input_api, output_api):
40     # Skip if nothing to do
41     source_filter = lambda x: input_api.FilterSourceFile(
42                 x, black_list=input_api.DEFAULT_BLACK_LIST + BLACK_LIST)
43     if not input_api.AffectedFiles(file_filter=source_filter):
44         return []
45
46     if input_api.is_committing:
47         message_type = output_api.PresubmitError
48     else:
49         message_type = output_api.PresubmitPromptWarning
50
51     pardir = input_api.os_path.pardir
52     run_bindings_tests_path = input_api.os_path.join(input_api.PresubmitLocalPath(), pardir, pardir, 'Tools', 'Scripts', 'run-bindings-tests')
53     cmd_name = 'run-bindings-tests'
54     if input_api.platform == 'win32':
55         # Windows needs some help.
56         cmd = [input_api.python_executable, run_bindings_tests_path]
57     else:
58         cmd = [run_bindings_tests_path]
59     test_cmd = input_api.Command(
60       name=cmd_name,
61       cmd=cmd,
62       kwargs={},
63       message=message_type)
64     if input_api.verbose:
65         print('Running ' + cmd_name)
66     return input_api.RunTests([test_cmd])
67
68
69 def CheckChangeOnUpload(input_api, output_api):
70     return _RunBindingsTests(input_api, output_api)
71
72
73 def CheckChangeOnCommit(input_api, output_api):
74     return _RunBindingsTests(input_api, output_api)