[Lldb-commits] [lldb] r124499 - /lldb/trunk/test/command_source/TestCommandSource.py
Johnny Chen
johnny.chen at apple.com
Fri Jan 28 11:30:12 PST 2011
Author: johnny
Date: Fri Jan 28 13:30:12 2011
New Revision: 124499
URL: http://llvm.org/viewvc/llvm-project?rev=124499&view=rev
Log:
Hardened the test_command_source() test case by actually capturing the output
from running the "script my.date()" lldb command and comparing it against our
expected result.
Modified:
lldb/trunk/test/command_source/TestCommandSource.py
Modified: lldb/trunk/test/command_source/TestCommandSource.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/command_source/TestCommandSource.py?rev=124499&r1=124498&r2=124499&view=diff
==============================================================================
--- lldb/trunk/test/command_source/TestCommandSource.py (original)
+++ lldb/trunk/test/command_source/TestCommandSource.py Fri Jan 28 13:30:12 2011
@@ -20,9 +20,23 @@
# the "my" package that defines the date() function.
self.runCmd("command source .lldb")
+ # Let's temporarily redirect the stdout to our StringIO session object
+ # in order to capture the script evaluation output.
+ old_stdout = sys.stdout
+ session = StringIO.StringIO()
+ sys.stdout = session
+
# Python should evaluate "my.date()" successfully.
self.runCmd("script my.date()")
+ import datetime
+ self.expect(session.getvalue(), "script my.date() runs successfully",
+ exe=False,
+ substrs = [str(datetime.date.today())])
+
+ # Now restore stdout to the way we were. :-)
+ sys.stdout = old_stdout
+
if __name__ == '__main__':
import atexit
More information about the lldb-commits
mailing list