<div dir="ltr">It's worth mentioning that pexpect is basically unusable on Windows, so there's still that.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 31, 2019 at 11:40 AM Pavel Labath <<a href="mailto:pavel@labath.sk">pavel@labath.sk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 31/01/2019 19:51, Zachary Turner wrote:<br>
 > FileCheck the ansi escape codes seems like one possibility.<br>
 ><br>
 > In general I think you don't actually need to test true interactivity,<br>
 > because the odds of there being a problem in the 2-3 lines of code that<br>
 > convert the keyboard press to something else in LLDB are very unlikely<br>
 > to be problematic, and the rest can be mocked.<br>
<br>
<br>
On 31/01/2019 20:02, Jim Ingham wrote:<br>
> All the traffic back and forth with the terminal happens in the IOHandlerEditLine.  We should be able to get our hands on the Debuggers IOHandler and feed characters directly to it, and read the results.  So we should be able to write this kind of test by driving the debugger to whatever state you need with SB API and then just run one command and get the output string directly from the IOHandler.  We should be able to then scan that output for color codes.  I don't think we need an external process inspection tool to do this sort of thing.<br>
> <br>
<br>
<br>
Libedit expect to work with a real terminal, so to test the code that <br>
interacts with libedit (and there's more than 3 lines of that), you'll <br>
need something that can create a pty, and read and write characters to <br>
it, regardless of whether you drive the test through FileCheck or SB API.<br>
<br>
"creating a pty, and reading and writing to it" is pretty much the <br>
definition of pexpect.<br>
<br>
I am not saying either of this approaches can't be made to work, but I <br>
am not sure who is going to do it. I fear that we are shooting ourselves <br>
in the foot banning pexpect and then pushing patches without tests <br>
because "it's hard".<br>
<br>
Just for fun, I tried to write a test to check the coloring of the <br>
prompt via pexpect. It was _literally_ three lines long:<br>
<br>
def test_colored_prompt_comes_out_right(self):<br>
     child = pexpect.spawn(lldbtest_config.lldbExec)<br>
     child.expect_exact("(lldb) \x1b[1G\x1b[2m(lldb) \x1b[22m\x1b[8G")<br>
<br>
<br>
BTW: I am not proposing we spend heroic efforts trying to port pexpect <br>
2.4 to python3. But I would consider using a newer version of pexpect to <br>
write tests ***where it makes sense to do so***. At least until someone <br>
comes up with a better (and not vapourware) alternative...<br>
<br>
pl<br>
</blockquote></div>