diff options
author | Robert Loehning <robert.loehning@theqtcompany.com> | 2016-02-08 18:18:28 +0100 |
---|---|---|
committer | Robert Loehning <robert.loehning@theqtcompany.com> | 2016-02-15 10:43:11 +0000 |
commit | 901d74121a616cda6a2d97c4c2284ef8f346e0fc (patch) | |
tree | 069f2965725f4f6209076993a1a31fd663524202 | |
parent | 6f7c4249ad087316f71566e10716c1f99d3fde56 (diff) | |
download | qt-creator-901d74121a616cda6a2d97c4c2284ef8f346e0fc.tar.gz |
Squish: Use existing tools for finding executables
Change-Id: Ic3e7f5db6d12e37f908df3290893768a5be4fa56
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
-rw-r--r-- | tests/system/shared/utils.py | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index 3f293ebf0d..475a2d63d5 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -138,37 +138,16 @@ def textUnderCursor(window, fromPos, toPos): return returnValue def which(program): - def is_exe(fpath): - return os.path.exists(fpath) and os.access(fpath, os.X_OK) - - def callableFile(path): - if is_exe(path): - return path - if platform.system() in ('Windows', 'Microsoft'): - for suffix in suffixes.split(os.pathsep): - if is_exe(path + suffix): - return path + suffix - return None - + # Don't use spawn.find_executable because it can't find .bat or + # .cmd files and doesn't check whether a file is executable (!) if platform.system() in ('Windows', 'Microsoft'): - suffixes = os.getenv("PATHEXT") - if not suffixes: - test.fatal("Can't read environment variable PATHEXT. Please check your installation.") - suffixes = "" - - fpath, fname = os.path.split(program) - if fpath: - return callableFile(program) + command = "where" + else: + command = "which" + foundPath = getOutputFromCmdline(command + " " + program) + if foundPath: + return foundPath.splitlines()[0] else: - if platform.system() in ('Windows', 'Microsoft'): - cf = callableFile(os.getcwd() + os.sep + program) - if cf: - return cf - for path in os.environ["PATH"].split(os.pathsep): - exe_file = os.path.join(path, program) - cf = callableFile(exe_file) - if cf: - return cf return None # this function removes the user files of given pro file(s) |