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

Unified Diff: presubmit_canned_checks.py

Issue 281013002: Recursively find all tests in a repo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: instantiate exception Created 6 years, 7 months 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
« no previous file with comments | « no previous file | presubmit_support.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index bd3c361f2742f1145df08607e22f754f7b61b705..56031b2c9828dfdfa9b82329751320e4f884b4c5 100644
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -562,6 +562,36 @@ def GetUnitTests(input_api, output_api, unit_tests, env=None):
return results
+def GetUnitTestsRecursively(input_api, output_api, directory,
+ whitelist, blacklist):
+ """Gets all files in the directory tree (git repo) that match the whitelist.
+
+ Restricts itself to only find files within the Change's source repo, not
+ dependencies.
+ """
+ def check(filename):
+ return (any(input_api.re.match(f, filename) for f in whitelist) and
+ not any(input_api.re.match(f, filename) for f in blacklist))
+
+ tests = []
+
+ to_run = found = 0
+ for filepath in input_api.change.AllFiles(directory):
+ found += 1
+ if check(filepath):
+ to_run += 1
+ tests.append(filepath)
+ input_api.logging.debug('Found %d files, running %d' % (found, to_run))
+ if not to_run:
+ return [
+ output_api.PresubmitPromptWarning(
+ 'Out of %d files, found none that matched w=%r, b=%r in directory %s'
+ % (found, whitelist, blacklist, directory))
+ ]
+
+ return GetUnitTests(input_api, output_api, tests)
+
+
def GetPythonUnitTests(input_api, output_api, unit_tests):
"""Run the unit tests out of process, capture the output and use the result
code to determine success.
@@ -744,7 +774,7 @@ def GetPylint(input_api, output_api, white_list=None, black_list=None,
if True:
return [GetPylintCmd(files)]
else:
- return map(GetPylintCmd, files)
+ return map(lambda x: GetPylintCmd([x]), files)
def RunPylint(input_api, *args, **kwargs):
« no previous file with comments | « no previous file | presubmit_support.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698