Add a '-u ENV_VAR_NAME' option to the test driver, whose purpose is to unset the said

environment variable before starting the test runner which executes the test cases and
may spawn child processes.  An example:

    ./dotest.py -u MY_ENV1 -u MY_ENV2 -v -p TestWatchLocationWithWatchSet.py

llvm-svn: 149304
This commit is contained in:
Johnny Chen 2012-01-31 00:38:03 +00:00
parent bd7ed6fe7c
commit 8f8a2a7774
1 changed files with 23 additions and 0 deletions

View File

@ -161,6 +161,9 @@ sdir_has_content = False
# svn_info stores the output from 'svn info lldb.base.dir'.
svn_info = ''
# The environment variables to unset before running the test cases.
unsets = []
# Default verbosity is 0.
verbose = 0
@ -229,6 +232,8 @@ where options:
with errored or failed status; if not specified, the test driver uses the
timestamp as the session dir name
-t : turn on tracing of lldb command and other detailed test executions
-u : specify an environment variable to unset before running the test cases
e.g., -u DYLD_INSERT_LIBRARIES -u MallocScribble'
-v : do verbose mode of unittest framework (print out each test case invocation)
-X : exclude a directory from consideration for test discovery
-X types => if 'types' appear in the pathname components of a potential testfile
@ -362,6 +367,7 @@ def parseOptionsAndInitTestdirs():
global regexp
global rdir
global sdir_name
global unsets
global verbose
global testdirs
@ -503,6 +509,13 @@ def parseOptionsAndInitTestdirs():
elif sys.argv[index].startswith('-t'):
os.environ["LLDB_COMMAND_TRACE"] = "YES"
index += 1
elif sys.argv[index].startswith('-u'):
# Increment by 1 to fetch the environment variable to unset.
index += 1
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
usage()
unsets.append(sys.argv[index])
index += 1
elif sys.argv[index].startswith('-v'):
verbose = 2
index += 1
@ -1008,6 +1021,16 @@ with open(fname, "w") as f:
print >> f, svn_info
print >> f, "Command invoked: %s\n" % getMyCommandLine()
#
# If we have environment variables to unset, do it here before we invoke the test runner.
#
for env_var in unsets :
if env_var in os.environ:
# From Python Doc: When unsetenv() is supported, deletion of items in os.environ
# is automatically translated into a corresponding call to unsetenv()
del os.environ[env_var]
#os.unsetenv(env_var)
#
# Invoke the default TextTestRunner to run the test suite, possibly iterating
# over different configurations.