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

Unified Diff: testing/test_env.py

Issue 10449089: Copy fix_python_path() in more standalone files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | tools/isolate/run_test_from_archive.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/test_env.py
diff --git a/testing/test_env.py b/testing/test_env.py
index 84967d16fcd9122944c99cacc4a2e90568620159..bbbcac529d1d7594213faa25304fefde9771adb2 100755
--- a/testing/test_env.py
+++ b/testing/test_env.py
@@ -13,6 +13,16 @@ import sys
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+def fix_python_path(cmd):
+ """Returns the fixed command line to call the right python executable."""
+ out = cmd[:]
+ if out[0] == 'python':
+ out[0] = sys.executable
+ elif out[0].endswith('.py'):
+ out.insert(0, sys.executable)
+ return out
+
+
def run_executable(cmd, env):
"""Runs an executable with:
- environment variable CR_SOURCE_ROOT set to the root directory.
@@ -25,8 +35,7 @@ def run_executable(cmd, env):
env['CR_SOURCE_ROOT'] = os.path.abspath(ROOT_DIR).encode('utf-8')
# Ensure paths are correctly separated on windows.
cmd[0] = cmd[0].replace('/', os.path.sep)
- if cmd[0].endswith('.py'):
- cmd.insert(0, sys.executable)
+ cmd = fix_python_path(cmd)
try:
return subprocess.call(cmd, env=env)
except OSError:
« no previous file with comments | « no previous file | tools/isolate/run_test_from_archive.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698