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

Unified Diff: presubmit_canned_checks.py

Issue 250693002: Adding custom environment variable support to presubmit_canned_checks.GetUnitTestsInDirectory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 8 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 | no next file » | 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 10a8d273d6d9f50f17446914be1076c29f5fd98b..bd3c361f2742f1145df08607e22f754f7b61b705 100644
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -496,7 +496,7 @@ def CheckTreeIsOpen(input_api, output_api,
return []
def GetUnitTestsInDirectory(
- input_api, output_api, directory, whitelist=None, blacklist=None):
+ input_api, output_api, directory, whitelist=None, blacklist=None, env=None):
"""Lists all files in a directory and runs them. Doesn't recurse.
It's mainly a wrapper for RunUnitTests. Use whitelist and blacklist to filter
@@ -528,10 +528,10 @@ def GetUnitTestsInDirectory(
'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, unit_tests)
+ return GetUnitTests(input_api, output_api, unit_tests, env)
-def GetUnitTests(input_api, output_api, unit_tests):
+def GetUnitTests(input_api, output_api, unit_tests, env=None):
"""Runs all unit tests in a directory.
On Windows, sys.executable is used for unit tests ending with ".py".
@@ -551,10 +551,13 @@ def GetUnitTests(input_api, output_api, unit_tests):
cmd.append(unit_test)
if input_api.verbose:
cmd.append('--verbose')
+ kwargs = {'cwd': input_api.PresubmitLocalPath()}
+ if env:
+ kwargs['env'] = env
results.append(input_api.Command(
name=unit_test,
cmd=cmd,
- kwargs={'cwd': input_api.PresubmitLocalPath()},
+ kwargs=kwargs,
message=message_type))
return results
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698