From 80c7e63a6db2f84e6425c429077e9c41f11243d2 Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Fri, 7 Jul 2017 00:22:11 +0000 Subject: [PATCH] [lit] Modify LIT to accept environment variable LIT_FILTER to select tests. This is especially useful when lit is invoked indirectly by the build system, and additional arguments can not be easily specified. Differential Revision: https://reviews.llvm.org/D35091 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307339 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CommandGuide/lit.rst | 7 +++++++ utils/lit/lit/main.py | 3 ++- utils/lit/tests/selecting.py | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/CommandGuide/lit.rst b/docs/CommandGuide/lit.rst index b8299d44d48..b4d15ef57b7 100644 --- a/docs/CommandGuide/lit.rst +++ b/docs/CommandGuide/lit.rst @@ -169,6 +169,13 @@ SELECTION OPTIONS must be in the range ``1..M``. The environment variable ``LIT_RUN_SHARD`` can also be used in place of this option. +.. option:: --filter=REGEXP + + Run only those tests whose name matches the regular expression specified in + ``REGEXP``. The environment variable ``LIT_FILTER`` can be also used in place + of this option, which is especially useful in environments where the call + to ``lit`` is issued indirectly. + ADDITIONAL OPTIONS ------------------ diff --git a/utils/lit/lit/main.py b/utils/lit/lit/main.py index a7f407fc210..530f962d336 100755 --- a/utils/lit/lit/main.py +++ b/utils/lit/lit/main.py @@ -262,7 +262,8 @@ def main_with_tmp(builtinParameters): selection_group.add_argument("--filter", metavar="REGEX", help=("Only run tests with paths matching the given " "regular expression"), - action="store", default=None) + action="store", + default=os.environ.get("LIT_FILTER")) selection_group.add_argument("--num-shards", dest="numShards", metavar="M", help="Split testsuite into M pieces and only run one", action="store", type=int, diff --git a/utils/lit/tests/selecting.py b/utils/lit/tests/selecting.py index 72d6fbabdc9..19ba240f9b0 100644 --- a/utils/lit/tests/selecting.py +++ b/utils/lit/tests/selecting.py @@ -7,6 +7,11 @@ # RUN: %{lit} --filter 'o[a-z]e' %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s # CHECK-FILTER: Testing: 2 of 5 tests +# Check that regex-filtering based on environment variables work. +# +# RUN: LIT_FILTER='o[a-z]e' %{lit} %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER-ENV %s +# CHECK-FILTER-ENV: Testing: 2 of 5 tests + # Check that maximum counts work # -- 2.49.0