We can't use sys.path[0] to determine the script directory because it doesn't work under a debugger

Test Plan: run tests with/without python debugger
Tested on OSX & Linux with PyCharm

Reviewers: chying, clayborg

Differential Revision: http://reviews.llvm.org/D9593

llvm-svn: 236957
This commit is contained in:
Vince Harron 2015-05-10 15:24:12 +00:00
parent 9753dd98b3
commit d5fa102d44
2 changed files with 10 additions and 5 deletions

View File

@ -148,7 +148,9 @@ def walk_and_invoke(test_root, dotest_options, num_threads):
return (timed_out, failed, passed)
def main():
test_root = sys.path[0]
# We can't use sys.path[0] to determine the script directory
# because it doesn't work under a debugger
test_root = os.path.dirname(os.path.realpath(__file__))
parser = OptionParser(usage="""\
Run lldb test suite using a separate process for each test file.

View File

@ -253,7 +253,9 @@ verbose = 1
progress_bar = False
# By default, search from the script directory.
testdirs = [ sys.path[0] ]
# We can't use sys.path[0] to determine the script directory
# because it doesn't work under a debugger
testdirs = [ os.path.dirname(os.path.realpath(__file__)) ]
# Separator string.
separator = '-' * 70
@ -375,6 +377,7 @@ o LLDB_LOG: if defined, specifies the log file pathname for the 'lldb' subsystem
o GDB_REMOTE_LOG: if defined, specifies the log file pathname for the
'process.gdb-remote' subsystem with a default option of 'packets' if
GDB_REMOTE_LOG_OPTION is not defined.
"""
sys.exit(0)
@ -933,10 +936,10 @@ def setupSysPath():
global lldbExecutablePath
# Get the directory containing the current script.
if ("DOTEST_PROFILE" in os.environ or "DOTEST_PDB" in os.environ) and "DOTEST_SCRIPT_DIR" in os.environ:
if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
else:
scriptPath = sys.path[0]
scriptPath = os.path.dirname(os.path.realpath(__file__))
if not scriptPath.endswith('test'):
print "This script expects to reside in lldb's test directory."
sys.exit(-1)
@ -955,7 +958,7 @@ def setupSysPath():
# Set up the LLDB_SRC environment variable, so that the tests can locate
# the LLDB source code.
os.environ["LLDB_SRC"] = os.path.join(sys.path[0], os.pardir)
os.environ["LLDB_SRC"] = os.path.join(scriptPath, os.pardir)
pluginPath = os.path.join(scriptPath, 'plugins')
pexpectPath = os.path.join(scriptPath, 'pexpect-2.4')