Add safe guard for when the 'expect' program cannot be located and skip the test.

llvm-svn: 150133
This commit is contained in:
Johnny Chen 2012-02-09 02:01:59 +00:00
parent abecb9ce3c
commit 57816730f0
2 changed files with 20 additions and 0 deletions

View File

@ -240,6 +240,23 @@ def pointer_size():
a_pointer = ctypes.c_void_p(0xffff)
return 8 * ctypes.sizeof(a_pointer)
def is_exe(fpath):
"""Returns true if fpath is an executable."""
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
def which(program):
"""Returns the full path to a program; None otherwise."""
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
class recording(StringIO.StringIO):
"""
A nice little context manager for recording the debugger interactions into

View File

@ -23,6 +23,9 @@ class CommandLineCompletionTestCase(TestBase):
def test_stty_dash_a_before_and_afetr_invoking_lldb_command(self):
"""Test that 'stty -a' displays the same output before and after running the lldb command."""
if not which('expect'):
self.skipTest("The 'expect' program cannot be located, skip the test")
# The expect prompt.
expect_prompt = "expect[0-9.]+> "
# The default lldb prompt.