<div dir="ltr"><div dir="ltr"><div dir="ltr">We have a similar option (-split-input-file) in `mlir-opt`: <a href="https://github.com/llvm/llvm-project/blob/master/mlir/test/Dialect/Affine/invalid.mlir">https://github.com/llvm/llvm-project/blob/master/mlir/test/Dialect/Affine/invalid.mlir</a><br></div><div dir="ltr"><br></div><div>With a single `RUN:` lit invocation the tool itself will loop over all the split sections in the file. This is convenient to test error cases where the tool would abort at the first error otherwise. I don't think we can easily achieve this with a single pipe and a separate `extract` command though?</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 13, 2020 at 6:43 PM Chen, Yuanfang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">`extract` +1 for consistency.<br>
<br>
________________________________________<br>
From: llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> on behalf of Fangrui Song via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
Sent: Monday, July 13, 2020 6:17 PM<br>
To: llvm-dev<br>
Subject: [llvm-dev] Multiple documents in one test file<br>
<br>
Sometimes it is convenient if we can specify multiple independent tests<br>
in one file. To give an example, let's discuss test/MC/ELF/debug-md5.s and<br>
test/MC/ELF/debug-md5-err.s (.file directive in the assembler).<br>
<br>
a) An invalid .file makes the whole file invalid. Because errors lead to a<br>
non-zero exit code, We have to use `RUN: not llvm-mc %s` for the whole file.<br>
This often lead to users placing good (`RUN: llvm-mc %s`) and bad tests (`RUN:<br>
not llvm-mc %s`) separately. For some features, having both good and bad tests<br>
in one file may improve readability.<br>
b) .debug_line is a global resource. Whenever we add a (valid) .file, we<br>
contribute an entry to the global resource. If we want to test some<br>
characteristics when include_directories[0] is A, and other characteristics<br>
when include_directories[0] is B, we have to use another test file.<br>
<br>
The arguments apply to many other types of tests (opt on .ll, llc on .ll and .mir, clang on .c, yaml2obj on .yaml, etc).<br>
<br>
I have a patch teaching llvm-mc about an option to split input: <a href="https://reviews.llvm.org/D83725" rel="noreferrer" target="_blank">https://reviews.llvm.org/D83725</a><br>
(30+ lines)<br>
<br>
In a comment, Richard Smith mentioned whether we can add a separate extractor utility:<br>
<br>
```<br>
# RUN: extract bb %s | llvm-mc - 2>&1 | FileCheck %s --check-prefix=BB<br>
<br>
or<br>
<br>
# RUN: extract bb %s -o %<a href="http://t.bb" rel="noreferrer" target="_blank">t.bb</a><br>
# RUN: llvm-mc %<a href="http://t.bb" rel="noreferrer" target="_blank">t.bb</a> 2>&1 | FileCheck %<a href="http://t.bb" rel="noreferrer" target="_blank">t.bb</a><br>
```<br>
<br>
The advantage is its versatility. The downside is somewhat verbose syntax.<br>
<br>
<br>
Some questoms:<br>
<br>
1. What do people think of the two approaches? An in-utility option vs a standalone utility.<br>
2. For llvm-mc, if we go with an option, is there a better name than --doc-id? David Blaikie proposed --asm-id<br>
(This is my personal preference, trading 30+ lines in a utility for simpler syntax)<br>
3. If we add a standalone utility, how shall we name it? (Note that llvm-extract exists, but people can probably distinguish 'extract' from llvm-extract<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>