OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 import re | 6 import re |
7 import sys | 7 import sys |
8 import subprocess | 8 import subprocess |
9 | 9 |
10 | 10 |
11 def RunCmdAndCheck(cmd, err_string, output_api, cwd=None): | 11 def RunCmdAndCheck(cmd, err_string, output_api, cwd=None, warning=False): |
12 results = [] | 12 results = [] |
13 p = subprocess.Popen(cmd, cwd=cwd, | 13 p = subprocess.Popen(cmd, cwd=cwd, |
14 stdout=subprocess.PIPE, | 14 stdout=subprocess.PIPE, |
15 stderr=subprocess.PIPE) | 15 stderr=subprocess.PIPE) |
16 (p_stdout, p_stderr) = p.communicate() | 16 (p_stdout, p_stderr) = p.communicate() |
17 if p.returncode: | 17 if p.returncode: |
18 results.append( | 18 if warning: |
19 output_api.PresubmitError(err_string, | 19 results.append(output_api.PresubmitPromptWarning( |
20 long_text=p_stderr)) | 20 '%s\n\n%s' % (err_string, p_stderr))) |
| 21 else: |
| 22 results.append( |
| 23 output_api.PresubmitError(err_string, |
| 24 long_text=p_stderr)) |
21 return results | 25 return results |
22 | 26 |
23 | 27 |
24 def RunUnittests(input_api, output_api): | 28 def RunUnittests(input_api, output_api): |
25 # Run some Generator unittests if the generator source was changed. | 29 # Run some Generator unittests if the generator source was changed. |
26 results = [] | 30 results = [] |
27 files = input_api.LocalPaths() | 31 files = input_api.LocalPaths() |
28 generator_files = [] | 32 generator_files = [] |
29 for filename in files: | 33 for filename in files: |
30 name_parts = filename.split(os.sep) | 34 name_parts = filename.split(os.sep) |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 nacl_sdk_files.append(filename) | 138 nacl_sdk_files.append(filename) |
135 | 139 |
136 if not nacl_sdk_files: | 140 if not nacl_sdk_files: |
137 return [] | 141 return [] |
138 | 142 |
139 verify_ppapi_py = os.path.join(input_api.change.RepositoryRoot(), | 143 verify_ppapi_py = os.path.join(input_api.change.RepositoryRoot(), |
140 'native_client_sdk', 'src', 'build_tools', | 144 'native_client_sdk', 'src', 'build_tools', |
141 'verify_ppapi.py') | 145 'verify_ppapi.py') |
142 cmd = [sys.executable, verify_ppapi_py] + nacl_sdk_files | 146 cmd = [sys.executable, verify_ppapi_py] + nacl_sdk_files |
143 return RunCmdAndCheck(cmd, | 147 return RunCmdAndCheck(cmd, |
144 'PPAPI Interface modified without updating NaCl SDK.', | 148 'PPAPI Interface modified without updating NaCl SDK.\n' |
145 output_api) | 149 '(note that some dev interfaces should not be added ' |
| 150 'the NaCl SDK; when in doubt, ask a ppapi OWNER.)', |
| 151 output_api, |
| 152 warning=True) |
146 | 153 |
147 # Verify that changes to ppapi/thunk/interfaces_* files have a corresponding | 154 # Verify that changes to ppapi/thunk/interfaces_* files have a corresponding |
148 # change to tools/metrics/histograms/histograms.xml for UMA tracking. | 155 # change to tools/metrics/histograms/histograms.xml for UMA tracking. |
149 def CheckHistogramXml(input_api, output_api): | 156 def CheckHistogramXml(input_api, output_api): |
150 # We can't use input_api.LocalPaths() here because we need to know about | 157 # We can't use input_api.LocalPaths() here because we need to know about |
151 # changes outside of ppapi/. See tools/depot_tools/presubmit_support.py for | 158 # changes outside of ppapi/. See tools/depot_tools/presubmit_support.py for |
152 # details on input_api. | 159 # details on input_api. |
153 files = input_api.change.AffectedFiles() | 160 files = input_api.change.AffectedFiles() |
154 | 161 |
155 INTERFACE_FILES = ('ppapi/thunk/interfaces_legacy.h', | 162 INTERFACE_FILES = ('ppapi/thunk/interfaces_legacy.h', |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 334 |
328 return results | 335 return results |
329 | 336 |
330 | 337 |
331 def CheckChangeOnUpload(input_api, output_api): | 338 def CheckChangeOnUpload(input_api, output_api): |
332 return CheckChange(input_api, output_api) | 339 return CheckChange(input_api, output_api) |
333 | 340 |
334 | 341 |
335 def CheckChangeOnCommit(input_api, output_api): | 342 def CheckChangeOnCommit(input_api, output_api): |
336 return CheckChange(input_api, output_api) | 343 return CheckChange(input_api, output_api) |
OLD | NEW |