[PATCH] D96662: [lit] Add --skip (inverse of --filter)

David Zarzycki via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 14 04:24:43 PST 2021


davezarzycki updated this revision to Diff 323609.
davezarzycki added a comment.

Add docs not included in the first diff.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96662/new/

https://reviews.llvm.org/D96662

Files:
  llvm/docs/CommandGuide/lit.rst
  llvm/utils/lit/lit/cl_arguments.py
  llvm/utils/lit/lit/main.py
  llvm/utils/lit/tests/selecting.py


Index: llvm/utils/lit/tests/selecting.py
===================================================================
--- llvm/utils/lit/tests/selecting.py
+++ 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
 
Index: llvm/utils/lit/lit/main.py
===================================================================
--- llvm/utils/lit/lit/main.py
+++ 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))
Index: llvm/utils/lit/lit/cl_arguments.py
===================================================================
--- llvm/utils/lit/lit/cl_arguments.py
+++ 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",
Index: llvm/docs/CommandGuide/lit.rst
===================================================================
--- llvm/docs/CommandGuide/lit.rst
+++ 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
 ------------------
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96662.323609.patch
Type: text/x-patch
Size: 4070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210214/67e15c5f/attachment.bin>


More information about the llvm-commits mailing list