summaryrefslogtreecommitdiffstats
path: root/testing/test_env.py
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-31 15:50:30 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-31 15:50:30 +0000
commit4bf4d6305a94b63fb3637930d7c4f514c5adca2d (patch)
treec48833f25acba325c9bbc81c5266608ca404b5ae /testing/test_env.py
parentc616499cee9dec4ee63a83fa130e70828420e4d0 (diff)
downloadchromium_src-4bf4d6305a94b63fb3637930d7c4f514c5adca2d.zip
chromium_src-4bf4d6305a94b63fb3637930d7c4f514c5adca2d.tar.gz
chromium_src-4bf4d6305a94b63fb3637930d7c4f514c5adca2d.tar.bz2
Copy fix_python_path() in more standalone files.
This script ensure that the current python is prepended on any python script invoked and that 'python' is replaced with the current python instance and not the system one. NOTRY=true TBR=csharp@chromium.org BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10449089 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139801 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'testing/test_env.py')
-rwxr-xr-xtesting/test_env.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/testing/test_env.py b/testing/test_env.py
index 84967d1..bbbcac5 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: