[all-commits] [llvm/llvm-project] 1041a9: [lit] Support %if ... %else syntax for RUN lines

Andrew Savonichev via All-commits all-commits at lists.llvm.org
Wed Apr 27 10:30:33 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1041a9642ba035fd2685f925911d705e8edf5bb0
      https://github.com/llvm/llvm-project/commit/1041a9642ba035fd2685f925911d705e8edf5bb0
  Author: Andrew Savonichev <andrew.savonichev at gmail.com>
  Date:   2022-04-27 (Wed, 27 Apr 2022)

  Changed paths:
    M llvm/docs/TestingGuide.rst
    M llvm/utils/lit/lit/TestRunner.py
    A llvm/utils/lit/tests/Inputs/shtest-if-else/lit.cfg
    A llvm/utils/lit/tests/Inputs/shtest-if-else/test-neg1.txt
    A llvm/utils/lit/tests/Inputs/shtest-if-else/test-neg2.txt
    A llvm/utils/lit/tests/Inputs/shtest-if-else/test-neg3.txt
    A llvm/utils/lit/tests/Inputs/shtest-if-else/test-neg4.txt
    A llvm/utils/lit/tests/Inputs/shtest-if-else/test.txt
    A llvm/utils/lit/tests/shtest-if-else.py

  Log Message:
  -----------
  [lit] Support %if ... %else syntax for RUN lines

This syntax allows to modify RUN lines based on features
available. For example:

    RUN: ... | FileCheck %s --check-prefix=%if windows %{CHECK-W%} %else %{CHECK-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

Differential Revision: https://reviews.llvm.org/D122569




More information about the All-commits mailing list