From 744959b9c9d7700a567926a4829f2e8cc6dc3cec Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 13 Jan 2016 18:11:45 +0000 Subject: Fix an issue where scripted commands would not actually print any of their output if an immediate output file was set in the result object via a Python file object Fixes rdar://24130303 llvm-svn: 257644 --- .../TestCommandScriptImmediateOutput.py | 37 ++++++++++++++++++++++ .../custom_command.py | 8 +++++ 2 files changed, 45 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py (limited to 'lldb/packages/Python/lldbsuite/test') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py new file mode 100644 index 00000000000..6484813f67b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py @@ -0,0 +1,37 @@ +""" +Test that LLDB correctly allows scripted commands to set an immediate output file +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.lldbpexpect import * + +class CommandScriptImmediateOutputTestCase (PExpectTest): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + PExpectTest.setUp(self) + + @skipIfRemote # test not remote-ready llvm.org/pr24813 + @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot") + @expectedFlakeyLinux("llvm.org/pr25172") + @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") + def test_command_script_immediate_output (self): + """Test that LLDB correctly allows scripted commands to set an immediate output file.""" + self.launch(timeout=5) + + script = os.path.join(os.getcwd(), 'custom_command.py') + prompt = "(lldb)" + + self.sendline('command script import %s' % script, patterns=[prompt]) + self.sendline('command script add -f custom_command.command_function mycommand', patterns=[prompt]) + self.sendline('mycommand', patterns='this is a test string, just a test string') + self.sendline('command script delete mycommand', patterns=[prompt]) + self.quit(gracefully=False) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py new file mode 100644 index 00000000000..a9749196ca7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py @@ -0,0 +1,8 @@ +from __future__ import print_function + +import sys + +def command_function(debugger, command, exe_ctx, result, internal_dict): + result.SetImmediateOutputFile(sys.__stdout__) + print('this is a test string, just a test string', file=result) + -- cgit v1.2.3