This syntax allows to modify RUN lines based on features
available. For example:
RUN: ... | FileCheck %s --check-prefix=%if windows %{W%} %else %{NON-W%} CHECK-W: ... CHECK-NON-W: ...
The whole command can be put under %if ... %else:
RUN: %if tool_available %{ %tool %} %else %{ true %}
or:
RUN: %if tool_available %{ %tool %}
If tool_available feature is missing, we'll have an empty command in this RUN line.
LIT used to emit an error for empty commands, but now it treats such commands as nop
in all cases.
Multi-line expressions are also supported:
RUN: %if tool_available %{ \ RUN: %tool \ RUN: %} %else %{ \ RUN: true \ RUN: %}
Background and motivation:
D121727 [NVPTX] Integrate ptxas to LIT tests
https://reviews.llvm.org/D121727
Would any of the following be expected to work?
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.