<div dir="ltr">Sounds good.  I think perhaps one reason a lot of tests are written using the commands is because not all functionality available through commands is available through the SB API.  Adrian is working on creating some tests for core dump debugging on Windows right now, and there's no way to access the functionality of "target create -c" through the API without using runCmd.  I'm sure there's hundreds of examples like this, so I think in a lot of cases people just don't want to take the time to make the necessary improvements to the SB API to expose the functionality they need.<div><br></div><div>In any case, if I know we agree, then I will keep an eye out for new tests that go in like this and push back against them in an effort to get more api tests in.</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 11, 2015 at 12:37 PM Jim Ingham <<a href="mailto:jingham@apple.com">jingham@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On Sep 11, 2015, at 11:47 AM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
><br>
> We'll probably rewrite tests that we find are failing specifically as a result of issues like this, but I agree it's not worth re-writing everything else except on an as-needed basis.<br>
><br>
> To make the distinction explicit and enforce it kind of at an organnizational level, would it be worth creating folders under lldb/test like lldb/test/commands, and recommending that all HandleCommand tests to go there?<br>
<br>
Yes, that might help.  Note that the test/README-testsuite explicitly states this policy:<br>
<br>
o Writing test cases:<br>
<br>
 We strongly prefer writing test cases using the SB API's rather than the runCmd & expect.<br>
 Unless you are actually testing some feature of the command line, please don't write<br>
 command based tests.  For historical reasons there are plenty of examples of tests in the<br>
 test suite that use runCmd where they shouldn't, but don't copy them, copy the plenty that<br>
 do use the SB API's instead.<br>
etc...<br>
<br>
Anything that will make that policy more explicit is to the good.<br>
<br>
Jim<br>
<br>
<br>
><br>
> Possibly unrelated question: But in regards to this api test vs. HandleCommand test situation, is that what the purpose of the @python_api_test decorator is (and is this decorator even still useful)?<br>
><br>
> On Fri, Sep 11, 2015 at 11:42 AM Jim Ingham <<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>> wrote:<br>
> I have held from the beginning that the only tests that should be written using HandleCommand are those that explicitly test command behavior, and if it is possible to write a test using the SB API you should always do it that way for the very reasons you cite.  Not everybody agreed with me at first, so we ended up with a bunch of tests that do complex things using HandleCommand where they really ought not to.  I'm not sure it is worth the time to go rewrite all those tests, but we shouldn't write any new tests that way.<br>
><br>
> Jim<br>
><br>
><br>
> > On Sep 11, 2015, at 11:33 AM, Zachary Turner via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a>> wrote:<br>
> ><br>
> > The past few weeks I've spent a lot of time xfailing the rest of the failing tests on windows so we can enable tests to run on the bots.<br>
> ><br>
> > One thing I ran into more frequently than I would have liked is that the tests were failing not because the functionality is broken, but because the substrings being grepped for in the output had a slightly different format on Windows.  The pattern for tests is frequently something like:<br>
> ><br>
> > result = runCommand(<some command>)<br>
> > self.expect(<result matches some regex>)<br>
> ><br>
> > A good example of this is that when you do a backtrace, on windows you might see a fully demangled function name such as a.out`void foo(int x), whereas on other platforms you might just see a.out`foo.<br>
> ><br>
> > I saw the reverse situation as well, where a test was passing but shouldn't have because it was actually broken, but due to the impreciseness of grepping output the grep was suceeding.  Specifically, this was happening on a test that verified function parameters.  it launched a program with 3 arguments, and then looked for "(int)argc=3" in the frame info.  It was broken on Windows because argc was pointing to junk memory, so it was actually printing "(int)argc=3248902" in the output.  Test was passing, even though it was broken.<br>
> ><br>
> > Rather than make the regexes more complicated, I think the right fix here is to stop using the command system and grepping to write tests.  Just go through the api for everything, including verifying the result.  In the second case, for example, you launch the process, set the breakpoint, wait for it to stop, find the argument named argc, and verify that it's value is 3.<br>
> ><br>
> > I don't want to propose going back and rewriting every single test to do this, but I want to see how people feel about moving toward this model going forward as the default method of writing tests.<br>
> ><br>
> > I do still think we need some tests that verify commands run, but I think those tests should focus not on doing complicated interactions with the debugger, and instead just verifying that things parse correctly and the command is configured correctly, with the underlying functionality being tested by the api tests.<br>
> ><br>
> > Thoughts?<br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > lldb-dev mailing list<br>
> > <a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a><br>
> > <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br>
><br>
<br>
</blockquote></div>