Index: llvm/trunk/docs/CommandGuide/lit.rst =================================================================== --- llvm/trunk/docs/CommandGuide/lit.rst +++ llvm/trunk/docs/CommandGuide/lit.rst @@ -169,6 +169,13 @@ 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 ------------------ Index: llvm/trunk/utils/lit/lit/main.py =================================================================== --- llvm/trunk/utils/lit/lit/main.py +++ llvm/trunk/utils/lit/lit/main.py @@ -262,7 +262,8 @@ 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, Index: llvm/trunk/utils/lit/tests/selecting.py =================================================================== --- llvm/trunk/utils/lit/tests/selecting.py +++ llvm/trunk/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 #