From 4bf4d6305a94b63fb3637930d7c4f514c5adca2d Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Thu, 31 May 2012 15:50:30 +0000 Subject: 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 --- testing/test_env.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'testing') 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: -- cgit v1.1