Chromium Code Reviews| Index: PRESUBMIT.py |
| diff --git a/PRESUBMIT.py b/PRESUBMIT.py |
| index 276db1e83b92d74b715347b5122c207c589bc3aa..a89bf00476e44f5a0efe009ce66a35a05bffe217 100755 |
| --- a/PRESUBMIT.py |
| +++ b/PRESUBMIT.py |
| @@ -9,6 +9,7 @@ |
| import json |
| import os |
| import re |
| +import subprocess |
| import sys |
| @@ -84,6 +85,18 @@ LEGACY_API_DIRS = ( |
| API_DIRS = NATIVE_API_DIRS[:] + LEGACY_API_DIRS[:] |
| +def _RunCommand(command, cwd): |
| + """Runs a command and returns the output from that command.""" |
| + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| + cwd=cwd) |
| + stdout = p.stdout.read() |
| + stderr = p.stderr.read() |
| + p.wait() |
| + p.stdout.close() |
| + p.stderr.close() |
| + return p.returncode, stdout, stderr |
| + |
| + |
| def _VerifyNativeApiHeadersListIsValid(input_api, output_api): |
| """Ensures the list of native API header directories is up to date.""" |
| non_existing_paths = [] |
| @@ -285,6 +298,19 @@ def _CheckNoMixingCAndCCSources(input_api, gn_files, output_api): |
| items=violating_gn_files.keys())] |
| return [] |
| +def _CheckNoPackageBoundaryViolations(input_api, gn_files, output_api): |
|
kjellander_webrtc
2017/01/19 10:51:26
nit: +1 blank line for top-level functions.
ehmaldonado_webrtc
2017/01/19 13:33:56
What do you mean? Should I also add a blank line b
kjellander_webrtc
2017/01/24 09:33:19
Yeah, all top-level definitions are to be separate
|
| + cwd = input_api.PresubmitLocalPath() |
| + script_path = os.path.join('tools-webrtc', 'check_package_boundaries.py') |
| + webrtc_path = os.path.join('webrtc') |
| + command = ['python', script_path, '--max_messages=1', webrtc_path] |
|
kjellander_webrtc
2017/01/19 10:51:26
Use sys.executable instead instead of 'python'. I
ehmaldonado_webrtc
2017/01/19 13:33:56
Done.
I also decided to get rid of --max-messages=
kjellander_webrtc
2017/01/24 09:33:19
Acknowledged.
|
| + command += [gn_file.LocalPath() for gn_file in gn_files] |
| + returncode, _, stderr = _RunCommand(command, cwd) |
| + if returncode: |
| + return [output_api.PresubmitError( |
| + 'There are package boundary violations in the following GN files:\n\n' |
| + '%s' % stderr)] |
| + return [] |
| + |
| def _CheckGnChanges(input_api, output_api): |
| source_file_filter = lambda x: input_api.FilterSourceFile( |
| x, white_list=(r'.+\.(gn|gni)$',)) |
| @@ -298,6 +324,8 @@ def _CheckGnChanges(input_api, output_api): |
| if gn_files: |
| result.extend(_CheckNoSourcesAbove(input_api, gn_files, output_api)) |
| result.extend(_CheckNoMixingCAndCCSources(input_api, gn_files, output_api)) |
| + result.extend(_CheckNoPackageBoundaryViolations( |
| + input_api, gn_files, output_api)) |
| return result |
| def _CheckUnwantedDependencies(input_api, output_api): |