diff options
author | Johnny Chen <johnny.chen@apple.com> | 2010-08-20 19:17:39 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2010-08-20 19:17:39 +0000 |
commit | 74f26b81880da1165ddac8c4b899b68b65d1d44e (patch) | |
tree | 962ba612053ca7eb2cee81c9e4d2898d4c10f40e | |
parent | 7110941d68c295170d36d8f21cd725bdc67957e8 (diff) | |
download | bcm5719-llvm-74f26b81880da1165ddac8c4b899b68b65d1d44e.tar.gz bcm5719-llvm-74f26b81880da1165ddac8c4b899b68b65d1d44e.zip |
Changed TestBase.expect() to allow default 'msg' arg. Converted TestHelp.py.
llvm-svn: 111671
-rw-r--r-- | lldb/test/help/TestHelp.py | 19 | ||||
-rw-r--r-- | lldb/test/lldbtest.py | 10 |
2 files changed, 10 insertions, 19 deletions
diff --git a/lldb/test/help/TestHelp.py b/lldb/test/help/TestHelp.py index 53ab9846c65..e73be7789a4 100644 --- a/lldb/test/help/TestHelp.py +++ b/lldb/test/help/TestHelp.py @@ -15,23 +15,14 @@ class TestHelpCommand(TestBase): 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__': diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 60ef05fc986..da282d699fa 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -141,7 +141,7 @@ class TestBase(unittest2.TestCase): 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 @@ class TestBase(unittest2.TestCase): 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 @@ class TestBase(unittest2.TestCase): print "Substring not matched:", str break - self.assertTrue(matched, msg) + self.assertTrue(matched, msg if msg else CMD_MSG(cmd)) |