<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 21, 2014 at 5:09 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="adM"><div class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Yes, it can be worked around. And the resulting test would look similar to this:</div><div><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div class="gmail_extra">


<div class="gmail_quote"><div><div><font face="courier new, monospace">// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">// RUN: clang-tidy %t.cpp -checks='-*,llvm-namespace-comment' -fix --</font></div>



</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">// RUN: FileCheck -input-file=%t.cpp -strict-whitespace %s</font></div></div></div></div><div class="gmail_extra">



<div class="gmail_quote"><div><font face="courier new, monospace">namespace {</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">} // namespace asdf</font></div>



</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">// CHECK-NOT: {{.*}}</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div>


<div>
<font face="courier new, monospace">// CHECK: {{^namespace {$}}</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">// CHECK-NEXT: {{^} // namespace$}}</font></div>



</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="courier new, monospace">// CHECK-NOT: {{.*}}</font></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div>



<br></div><div>This can be simplified by extracting all the RUN: commands to a script (e.g. check_clang_tidy_fix.sh, which is used </div></div></div></div></blockquote></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="adM"><div class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>in redundant-smartptr-get-fix.cpp), but then the test will require shell, which iiuc won't allow it to run on Windows, for example.</div>
</div></div></div></blockquote></div></div></blockquote><div><br></div><div>Instead you could just teach clang-tidy to output on stdout, and teach FileCheck to strip the comments it matches from the input (perhaps with a flag). Then the RUN: lines should boil down to the standard line with a tool piped to FileCheck... </div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="adM"><div class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">


<div><br></div><div>And if you compare this version with the unit test above, and consider also factors like portability, performance, convenience of running a single test and debugging it, etc., what would you prefer? I would definitely prefer the unit-test version.</div>

</div></div></div></blockquote><div><br></div></div></div><div>I agree, with the current state of FileCheck, that is not pretty.</div><div><br></div><div>However, I think that by using CHECK-LABEL and adding two features to FileCheck it could be pretty much as simple and clean as I described. The two features would be to have ignoring CHECK lines themselves be built-in to FileCheck (IIRC this has been needed in the past for clang-modernize so this feature would be a nice addition). A CHECK-EXACT would make matching the exact text a lot cleaner. But yeah, that requires some work on FileCheck.</div>
</blockquote></div><br>FWIW, I think that doing the work to make tools like this easily testable with FileCheck would be worthwhile. I like unittests too, and like the fact that we exercise libraries directly, but I think for a tool which is fundamentally doing text -> text transformation, it probably makes sense to use FileCheck.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">If anything, I think clang-format is going to be the exception to this rule because it is *only* changing the whitespace, where as I suspect for everything other than clang-format we want to ignore whitespace entirely (because it is fixed and the fixes tested in clang-format) and use something like the CHECK-EXACT than Sean hypothesizes.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">-Chandler</div></div>