diff --git a/i/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst --- a/i/llvm/docs/CommandGuide/lit.rst +++ b/llvm/docs/CommandGuide/lit.rst @@ -209,6 +209,13 @@ of this option, which is especially useful in environments where the call to ``lit`` is issued indirectly. +.. option:: --skip=REGEXP + + Skip those tests whose name matches the regular expression specified in + ``REGEXP``. The environment variable ``LIT_SKIP`` 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/i/llvm/utils/lit/lit/cl_arguments.py b/llvm/utils/lit/lit/cl_arguments.py --- a/i/llvm/utils/lit/lit/cl_arguments.py +++ b/llvm/utils/lit/lit/cl_arguments.py @@ -158,6 +158,11 @@ type=_case_insensitive_regex, help="Only run tests with paths matching the given regular expression", default=os.environ.get("LIT_FILTER", ".*")) + selection_group.add_argument("--skip", + metavar="REGEX", + type=_case_insensitive_regex, + help="Skip tests with paths matching the given regular expression", + default=os.environ.get("LIT_SKIP", "^$")) selection_group.add_argument("--num-shards", dest="numShards", metavar="M", diff --git a/i/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py --- a/i/llvm/utils/lit/lit/main.py +++ b/llvm/utils/lit/lit/main.py @@ -68,7 +68,8 @@ determine_order(discovered_tests, opts.order) selected_tests = [t for t in discovered_tests if - opts.filter.search(t.getFullName())] + opts.filter.search(t.getFullName()) + and not opts.skip.search(t.getFullName())] if not selected_tests: sys.stderr.write('error: filter did not match any tests ' '(of %d discovered). ' % len(discovered_tests)) diff --git a/i/llvm/utils/lit/tests/selecting.py b/llvm/utils/lit/tests/selecting.py --- a/i/llvm/utils/lit/tests/selecting.py +++ b/llvm/utils/lit/tests/selecting.py @@ -9,9 +9,12 @@ # CHECK-BAD-PATH: error: did not discover any tests for provided path(s) # Check that we exit with an error if we filter out all tests, but allow it with --allow-empty-runs. +# Check that we exit with an error if we skip all tests, but allow it with --allow-empty-runs. # # RUN: not %{lit} --filter 'nonexistent' %{inputs}/discovery 2>&1 | FileCheck --check-prefixes=CHECK-BAD-FILTER,CHECK-BAD-FILTER-ERROR %s # RUN: %{lit} --filter 'nonexistent' --allow-empty-runs %{inputs}/discovery 2>&1 | FileCheck --check-prefixes=CHECK-BAD-FILTER,CHECK-BAD-FILTER-ALLOW %s +# RUN: not %{lit} --skip '.*' %{inputs}/discovery 2>&1 | FileCheck --check-prefixes=CHECK-BAD-FILTER,CHECK-BAD-FILTER-ERROR %s +# RUN: %{lit} --skip '.*' --allow-empty-runs %{inputs}/discovery 2>&1 | FileCheck --check-prefixes=CHECK-BAD-FILTER,CHECK-BAD-FILTER-ALLOW %s # CHECK-BAD-FILTER: error: filter did not match any tests (of 5 discovered). # CHECK-BAD-FILTER-ERROR: Use '--allow-empty-runs' to suppress this error. # CHECK-BAD-FILTER-ALLOW: Suppressing error because '--allow-empty-runs' was specified. @@ -21,6 +24,9 @@ # RUN: %{lit} --filter 'o[a-z]e' %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s # RUN: %{lit} --filter 'O[A-Z]E' %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s # RUN: env LIT_FILTER='o[a-z]e' %{lit} %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s +# RUN: %{lit} --skip 'test-t[a-z]' %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s +# RUN: %{lit} --skip 'test-t[A-Z]' %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s +# RUN: env LIT_SKIP='test-t[a-z]' %{lit} %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s # CHECK-FILTER: Testing: 2 of 5 tests # CHECK-FILTER: Excluded: 3