<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Nov 14, 2013, at 12:52 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:<div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Nov 14, 2013 at 10:58 AM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank" class="cremed">clattner@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div class="im">On Nov 14, 2013, at 3:16 AM, Chandler Carruth <<a href="mailto:chandlerc@google.com" target="_blank" class="cremed">chandlerc@google.com</a>> wrote:</div>
<div><div class="im"><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>However, when we are adding interfaces or generic utilities to LLVM (admittedly, not the common case) I don't think we do ourselves any favors by using only half of the available tools to write unit tests for them.</div>
</div></div></div></blockquote><div><br></div></div><div>I agree in principle, but it leads me to a different conclusion. We have other great testing support, which means that the mocking *should* only be used sparingly. Given that it will not be used much, the cost of carrying it around (and for people to learn how to use/maintain it) is high.</div>
</div></div></blockquote><div><br></div><div>I think the cost of carrying it around is essentially zero. I'm happy to do any of the maintenance. </div></div></div></div></blockquote><div><br></div><div>I'm not talking about the cost of maintaining gmock itself. I'm talking about the cost of maintaining tests that are ultimately written around it. Alp eloquently made the point up-thread.</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>People who don't know how to use it or want to learn how to use it don't need to use it. If it isn't making their job of writing tests sufficiently easier to justify, then they don't use it. I see this as a good pattern.</div>
</div></div></div></blockquote><div><br></div><div>This is factually not the case. I've had to learn a lot about gtest just to figure out its wonky macro system, figure out how to rerun the failing tests, etc.</div><div><br></div><div>It is also an empirical fact that linking all the unit tests slows down my build in a very noticeable way... every time I build, even though I derive near zero benefit from it.</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;"><div style="word-wrap:break-word"><div><br></div><div>I’ve said this before, but I’m not a fan of our current use of gtest for unit testing. I have never had the unit tests catch a bug, but I have had to update the tests countless times. At least for my purposes, the unit tests cause significantly more harm than good - and it certainly isn’t because I write perfect code. :-)</div>
</div></blockquote><div><br></div><div>I seem to recall code review spotting a bug that would have been caught by a unittest were one written.</div></div></div></div></blockquote><div><br></div><div>Right, validating my assertion that while TDD and unit testing are good in general, they may not be right for LLVM. In LLVM, we have mature tests of other sorts, as well as a strong process of review.</div><div><br></div><div>Further, even if you guys didn't notice the bug immediately, I would have noticed it in my (planned) next commit. That commit was the code that used it. You don't need a unit test to catch obvious bozo bugs like the one you are referring to.</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Even so, you aren't the only one we're trying to optimize for. A lot of people have written unittests using the framework, and I think the incremental cost of making it a slightly more powerful framework (by adding one complementary library) is really low.</div></div></div></div></blockquote><div><br></div><div>I am trying to optimize for tests that add value: this means that they find real bugs that would otherwise be expensive to find, and do so at low cost. The goal is not to have tests for their own sake.</div><div><br></div><div>I fully understand that tests and mocking and other tooling can be useful to bring up a major new subsystem like the passmanager. I just don't think it makes sense to carry around a bringup tool forever in the source tree. </div><div><br></div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>There is definitely a culture/religion around testing and TDD, and I am well aware that many projects don’t have proper tests (which LLVM doesn’t suffer from). However, there is a pragmatic balance to be struck here, and I personally think that adding gmock and pushing the unit tests stuff even further is a bad use of testing time (i.e., increases test cycles for make check) and maintenance time (updating tests given that we don’t have a stable API).</div>
</div></blockquote><div><br></div><div>These two things (adding gmock and pushing unittests further) are not necessarily related, and I don't plan to do the latter. I'm asking if doing the former would cause significant problems for any consumers of LLVM, and I don't hear any statements to that effect except for David Chisnall's which I responded to specifically.</div>
<div><br></div><div>I'm not trying to make LLVM use unittests everywhere, I'm just trying to get a tool added to the toolbox so that a unittest I'm already writing can be written more simply and in a more maintainable fashion.</div>
</div></div></div>
</blockquote></div><br><div>I see gmock tests as something that will make API evolution much more difficult, and believe that it will be much more of a problem in practice than unit tests, because it necessarily requires more internal implementation details to be exposed to the testing framework.</div><div><br></div><div>-Chris</div></body></html>