[llvm] r307339 - [lit] Modify LIT to accept environment variable LIT_FILTER to select tests.

George Karpenkov via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 6 17:22:11 PDT 2017


Author: george.karpenkov
Date: Thu Jul  6 17:22:11 2017
New Revision: 307339

URL: http://llvm.org/viewvc/llvm-project?rev=307339&view=rev
Log:
[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

Modified:
    llvm/trunk/docs/CommandGuide/lit.rst
    llvm/trunk/utils/lit/lit/main.py
    llvm/trunk/utils/lit/tests/selecting.py

Modified: llvm/trunk/docs/CommandGuide/lit.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lit.rst?rev=307339&r1=307338&r2=307339&view=diff
==============================================================================
--- llvm/trunk/docs/CommandGuide/lit.rst (original)
+++ llvm/trunk/docs/CommandGuide/lit.rst Thu Jul  6 17:22:11 2017
@@ -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
 ------------------
 

Modified: llvm/trunk/utils/lit/lit/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/main.py?rev=307339&r1=307338&r2=307339&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/main.py (original)
+++ llvm/trunk/utils/lit/lit/main.py Thu Jul  6 17:22:11 2017
@@ -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,

Modified: llvm/trunk/utils/lit/tests/selecting.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/selecting.py?rev=307339&r1=307338&r2=307339&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/selecting.py (original)
+++ llvm/trunk/utils/lit/tests/selecting.py Thu Jul  6 17:22:11 2017
@@ -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
 #




More information about the llvm-commits mailing list