Index: tools/checkteamtags/PRESUBMIT.py |
diff --git a/tools/checkteamtags/PRESUBMIT.py b/tools/checkteamtags/PRESUBMIT.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..57acdef07eecd12c2161e8ce44dd55f8564b855e |
--- /dev/null |
+++ b/tools/checkteamtags/PRESUBMIT.py |
@@ -0,0 +1,46 @@ |
+# 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.
|
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""Top-level presubmit script for checkteamtags |
+ |
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
+details on the presubmit API. |
+""" |
+ |
+import subprocess |
+ |
+ |
+def CheckChangeOnUpload(input_api, output_api): |
+ return _CommonChecks(input_api, output_api) |
+ |
+ |
+def CheckChangeOnCommit(input_api, output_api): |
+ return _CommonChecks(input_api, output_api) |
+ |
+ |
+def _CommonChecks(input_api, output_api): |
+ """Does all presubmit checks for chekteamtags.""" |
+ results = [] |
+ results.extend(_RunUnitTests(input_api, output_api)) |
+ results.extend(_RunPyLint(input_api, output_api)) |
+ return results |
+ |
+def _RunUnitTests(input_api, output_api): |
+ """Runs unit tests for checkteamtags.""" |
+ repo_root = input_api.change.RepositoryRoot() |
+ checkteamtags_dir = input_api.os_path.join(repo_root, 'tools', |
+ 'checkteamtags') |
+ test_runner = input_api.os_path.join(checkteamtags_dir, 'run_tests') |
+ return_code = subprocess.call(['python', test_runner]) |
+ if return_code: |
+ message = 'Checkteamtags unit tests did not all pass.' |
+ return [output_api.PresubmitError(message)] |
+ return [] |
+ |
+ |
+def _RunPyLint(input_api, output_api): |
+ """Runs unit tests for checkteamtags.""" |
+ tests = input_api.canned_checks.GetPylint( |
+ input_api, output_api) |
+ return input_api.RunTests(tests) |