[Lldb-commits] [lldb] r111671 - in /lldb/trunk/test: help/TestHelp.py lldbtest.py
Johnny Chen
johnny.chen at apple.com
Fri Aug 20 12:17:39 PDT 2010
Author: johnny
Date: Fri Aug 20 14:17:39 2010
New Revision: 111671
URL: http://llvm.org/viewvc/llvm-project?rev=111671&view=rev
Log:
Changed TestBase.expect() to allow default 'msg' arg. Converted TestHelp.py.
Modified:
lldb/trunk/test/help/TestHelp.py
lldb/trunk/test/lldbtest.py
Modified: lldb/trunk/test/help/TestHelp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=111671&r1=111670&r2=111671&view=diff
==============================================================================
--- lldb/trunk/test/help/TestHelp.py (original)
+++ lldb/trunk/test/help/TestHelp.py Fri Aug 20 14:17:39 2010
@@ -15,23 +15,14 @@
def test_simplehelp(self):
"""A simple test of 'help' command and its output."""
- res = lldb.SBCommandReturnObject()
- self.ci.HandleCommand("help", res)
- self.assertTrue(res.Succeeded() and
- res.GetOutput().startswith(
- 'The following is a list of built-in, permanent debugger commands'),
- CMD_MSG('help'))
+ self.expect("help",
+ startstr = 'The following is a list of built-in, permanent debugger commands')
def test_help_should_not_hang_emacsshell(self):
"""Command 'set term-width 0' should not hang the help command."""
- res = lldb.SBCommandReturnObject()
- self.ci.HandleCommand("set term-width 0", res)
- self.assertTrue(res.Succeeded(), CMD_MSG('set term-width 0'))
- self.ci.HandleCommand("help", res)
- self.assertTrue(res.Succeeded() and
- res.GetOutput().startswith(
- 'The following is a list of built-in, permanent debugger commands'),
- CMD_MSG('help'))
+ self.runCmd("set term-width 0")
+ self.expect("help",
+ startstr = 'The following is a list of built-in, permanent debugger commands')
if __name__ == '__main__':
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=111671&r1=111670&r2=111671&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri Aug 20 14:17:39 2010
@@ -141,7 +141,7 @@
self.assertTrue(self.res.Succeeded(),
msg if msg else CMD_MSG(cmd))
- def expect(self, cmd, msg, startstr=None, substrs=None, verbose=False):
+ def expect(self, cmd, msg=None, startstr=None, substrs=None, verbose=False):
"""
Similar to runCmd; with additional expect style output matching ability.
@@ -150,11 +150,11 @@
message. We expect the output from running the command to start with
'startstr' and matches the substrings contained in 'substrs'.
"""
- # Fail fast if 'msg' is not meaningful.
- if not msg or len(msg) == 0:
- raise Exception("Bad 'msg' parameter encountered")
+
+ # First run the command.
self.runCmd(cmd, verbose = (True if verbose else False))
+ # Then compare the output against expected strings.
output = self.res.GetOutput()
matched = output.startswith(startstr) if startstr else True
@@ -169,5 +169,5 @@
print "Substring not matched:", str
break
- self.assertTrue(matched, msg)
+ self.assertTrue(matched, msg if msg else CMD_MSG(cmd))
More information about the lldb-commits
mailing list