[PATCH] D122569: [lit] Support %if ... %else syntax for RUN lines
Andrew Savonichev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 28 12:08:32 PDT 2022
asavonic added inline comments.
================
Comment at: llvm/docs/TestingGuide.rst:615
+``%if feature {<if branch>} %else {<else branch>}``
+
----------------
tra wrote:
> Would any of the following be expected to work?
> - `%if feature {do_something} | FileCheck %s` -- this will probably fail as empty substitution would produce no output to check
> - `%if feature {do_something | FileCheck %s}` -- this would probably work.
> - `%if featureA { %if featureB {do_AB} %else {do_A_notB}} %else {do_notA}` -- I suspect we'll fail to parse it correctly.
>
> I'd document that we currently can't nest those `%if/%else` and, maybe add the `%if feature {do_something | FileCheck %s}` as a canonical example of how to use it for conditional output-checking tests.
>
> Would any of the following be expected to work?
> - `%if feature {do_something} | FileCheck %s` -- this will probably fail as empty substitution would produce no output to check
Right. If the feature is not available then we'll get ` | FileCheck %s`.
> - `%if feature {do_something | FileCheck %s}` -- this would probably work.
This does not work for verbose output: LIT formats a command into `echo "RUN at line #"; ${command};` and if `${command}` is an empty string we'll get `echo "RUN at line #"; ;`. Bash cannot parse the double semicolon at the end.
We can probably handle this as a special case.
> - `%if featureA { %if featureB {do_AB} %else {do_A_notB}} %else {do_notA}` -- I suspect we'll fail to parse it correctly.
Recursive substitution actually works if `config.recursiveExpansionLimit` is set in lit.cfg. I'll this case to the test.
>
> I'd document that we currently can't nest those `%if/%else` and, maybe add the `%if feature {do_something | FileCheck %s}` as a canonical example of how to use it for conditional output-checking tests.
>
As I mentioned above, a canonical example would be:
`%if feature {do_something | FileCheck %s} %else {true}`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122569/new/
https://reviews.llvm.org/D122569
More information about the llvm-commits
mailing list