Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
|
stgao
2017/01/03 22:46:59
nit: 2013 -> 2016/2017?
RobertoCN
2017/01/04 18:48:59
Done.
| |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """Top-level presubmit script for checkteamtags | |
| 6 | |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | |
| 8 details on the presubmit API. | |
| 9 """ | |
| 10 | |
| 11 import subprocess | |
| 12 | |
| 13 | |
| 14 def CheckChangeOnUpload(input_api, output_api): | |
| 15 return _CommonChecks(input_api, output_api) | |
| 16 | |
| 17 | |
| 18 def CheckChangeOnCommit(input_api, output_api): | |
| 19 return _CommonChecks(input_api, output_api) | |
| 20 | |
| 21 | |
| 22 def _CommonChecks(input_api, output_api): | |
| 23 """Does all presubmit checks for chekteamtags.""" | |
| 24 results = [] | |
| 25 results.extend(_RunUnitTests(input_api, output_api)) | |
| 26 results.extend(_RunPyLint(input_api, output_api)) | |
| 27 return results | |
| 28 | |
| 29 def _RunUnitTests(input_api, output_api): | |
| 30 """Runs unit tests for checkteamtags.""" | |
| 31 repo_root = input_api.change.RepositoryRoot() | |
| 32 checkteamtags_dir = input_api.os_path.join(repo_root, 'tools', | |
| 33 'checkteamtags') | |
| 34 test_runner = input_api.os_path.join(checkteamtags_dir, 'run_tests') | |
| 35 return_code = subprocess.call(['python', test_runner]) | |
| 36 if return_code: | |
| 37 message = 'Checkteamtags unit tests did not all pass.' | |
| 38 return [output_api.PresubmitError(message)] | |
| 39 return [] | |
| 40 | |
| 41 | |
| 42 def _RunPyLint(input_api, output_api): | |
| 43 """Runs unit tests for checkteamtags.""" | |
| 44 tests = input_api.canned_checks.GetPylint( | |
| 45 input_api, output_api) | |
| 46 return input_api.RunTests(tests) | |
| OLD | NEW |