<div dir="ltr">There were some back and forth comments on the review. To summarize, I'm strongly in favor of having a tool in-tree that splits files on some delimiter inside a comment. Chandler is strongly opposed to having test files that aren't completely valid standalone files as part of the test suite. For example, a smart editor or IDE would put red squigglies on this code because it's ill-formed as is:<div><br></div><div>// RUN: FileEdit %s --res_dir %t</div><div>// RUN: clang %t/a.cpp %t/b.cpp -o %t.exe</div><div>// FILESPLIT: a.cpp</div><div>static int x = 1;</div><div>int main() {}</div><div>// FILESPLIT: b.cpp<br></div><div>static int x = 2; // error about redefining x<br></div><div><br></div><div>You'd get the same kind of issues with macro redefinitions. I don't see this as a big problem, and I'd rather keep the test case in one file over using separate files in %S/Inputs. His proposed alternative is to use in-language mechanisms when possible. This would mean using the C preprocessor for C, .if directives for assembler, and llvm-extract for LTO test cases in IR.</div><div><br></div><div>Hopefully I haven't misrepresented Chandler's perspective on this.</div><div><br></div><div>Unless someone else comes forward and says they hate having to add small files to %S/Inputs and they really want a text file splitting utility, I think we're going to drop this for now. I'm happy enough to hack together lld test cases with .if.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 28, 2017 at 10:14 AM, Zachary Turner via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I've put up <a href="https://reviews.llvm.org/D34764" target="_blank">D34764</a> for review.  I'll paste the review summary message below for the purposes of having this message be self-contained.  Comments welcome, either here or on the review thread.<br><br>-----------<br><br><br>This introduces a new utility, which I'm calling FileEdit, which is intended to increase portability in tests across platforms and shells, while adding some additional functionality that enables us to write more concise, easily-understandable, and easily-creatable tests.<br><br>To elaborate on the first point, a (somewhat) common pattern in tests is to run sed against the test file, replacing certain fixed strings in the check statements with values that are known only during the run line. For example, you might compile something and get some debug info with a path relative to the test output directory, and you want to write a check statement that checks the path is correct. Or you might want to run the same command multiple times where only the value of a single command line argument is changed, which would cause some small sectino of the output to be different but the test to otherwise be identical. In these and other cases, you may wish to use the same CHECK prefix with a replacement variable.<br><br>sed solves this, but a) it's needlessly complicated and not everyone is a Level 99 sed wizard, and b) There are real portability issues when it comes to escaping and slashes that are not easily solvable.<br><br>For the second point, lit tests are convenient to write when only have 1 input file to whatever tool we wish to exercise, because we can inline the text of the input file within the test file itself, meaning a test is entirely self contained.<br><br>This is not true anymore when a test requires multiple input files (for example, consider the case where you want to compile 2 .cpp files into separate object files and link them together. It would be nice we could have the same level of test-isolation for these kinds of tests as well.<br><br>This patch addresses both of the above issues, but one could easily imagine other use cases for a tool such as this, so it has potential for a larger feature set.<br><br>It addresses the first by having a command line option --replace=<string>, where <string> is of the form s/pattern/replace/ and behaves in a mostly intuitive way -- it replaces all occurrences of pattern (quirk: pattern is not a regex, it is a string literal).<br><br>It addresses the second by scanning lines for a directive that identifies the beginning of a file, and it copies everything that follows (until the next directive) to the corresponding file. For example,<div><br>{!-- Foo.cpp</div><div>int main(int argc, char **argv) {</div><div>  return 0;</div><div>}<br><br>would create a file named Foo.cpp with the aforementioned text, which can then be referenced in a run line.</div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>