Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: tools/checkteamtags/PRESUBMIT.py

Issue 2601773004: Adding check for team and component tags in owners files. (Closed)
Patch Set: Addressing comments and adding tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698