summaryrefslogtreecommitdiffstats
path: root/lldb/test/command_source/TestCommandSource.py
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-01-28 19:30:12 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-01-28 19:30:12 +0000
commitc03a362b1666dad0b66040ac7cf77b3803fc4a09 (patch)
tree0ae41cb9250e045dfcc3e173aadfa6714b6cc729 /lldb/test/command_source/TestCommandSource.py
parentcd9ae95ae724fc8198eaa7376aba4a1ac69349fb (diff)
downloadbcm5719-llvm-c03a362b1666dad0b66040ac7cf77b3803fc4a09.tar.gz
bcm5719-llvm-c03a362b1666dad0b66040ac7cf77b3803fc4a09.zip
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. llvm-svn: 124499
Diffstat (limited to 'lldb/test/command_source/TestCommandSource.py')
-rw-r--r--lldb/test/command_source/TestCommandSource.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lldb/test/command_source/TestCommandSource.py b/lldb/test/command_source/TestCommandSource.py
index b7ae947c5ce..0f34eb464a5 100644
--- a/lldb/test/command_source/TestCommandSource.py
+++ b/lldb/test/command_source/TestCommandSource.py
@@ -20,9 +20,23 @@ class CommandSourceTestCase(TestBase):
# 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
OpenPOWER on IntegriCloud