[PATCH] D122569: [lit] Support %if ... %else syntax for RUN lines

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 29 14:30:55 PDT 2022


probinson added inline comments.


================
Comment at: llvm/utils/lit/tests/shtest-if-else.py:1
+# RUN: %{lit} -v --show-all %{inputs}/shtest-if-else | FileCheck %s
+# END.
----------------
asavonic wrote:
> tra wrote:
> > I'd use the full name `%{inputs}/shtest-if-else/test.txt`. 
> > This way it's obvious how the input file is used and it avoids accidentally picking up some other file we may eventually have in that directory.
> > 
> > Perhaps it would make sense to incorporate the test.txt into this file. E.g add another RUN line to generate the test input file and then run lit on it.
> > This would allow  interleaving the RUN/check directives in the same source. Right now it's a bit of a pain to follow what we're exacuting and which output it's supposed to generate.
> > 
> > E.g. we could do something like this:
> > ```
> > RUN: grep LITRUN %s | sed -e 's/LITRUN/RUN/' > %t/test.txt
> > RUN: grep LITCFG %s | sed -e 's/# LITCFG://' > %t/lit.cfg
> > RUN: %{lit} -v --show-all %t.txt | FileCheck %s
> > 
> > # LITCFG: lit config lines go here.
> > 
> > # LITRUN: echo XX %if feature {YY} ZZ
> > # CHECK-NEXT: 'RUN: at line 32'; echo XX YY ZZ
> > # LITRUN: ...
> > # CHECK-NEXT: ...
> > ```
> > ```
> > RUN: grep LITRUN %s | sed -e 's/LITRUN/RUN/' > %t/test.txt
> > RUN: grep LITCFG %s | sed -e 's/# LITCFG://' > %t/lit.cfg
> > ```
> I wonder if grep and sed are available (and required) for windows builds. Probably not.
> In any case, I don't like this separation between inputs and checks either, so I'll try to figure out the way to combine them in one file.
You probably want split-file which is an LLVM-built tool.


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