[llvm] [lit] Support wildcard in --xfail-not option (PR #151191)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 30 15:52:11 PDT 2025
https://github.com/mtrofin updated https://github.com/llvm/llvm-project/pull/151191
>From d400000e50384b4d39b456ae2028ac5f9bedec3b Mon Sep 17 00:00:00 2001
From: Mircea Trofin <mtrofin at google.com>
Date: Tue, 29 Jul 2025 09:41:17 -0700
Subject: [PATCH] option to wildcard xfail-not
---
llvm/utils/lit/lit/Test.py | 5 ++++-
llvm/utils/lit/lit/TestRunner.py | 2 ++
llvm/utils/lit/lit/cl_arguments.py | 6 ++++++
llvm/utils/lit/lit/main.py | 2 ++
llvm/utils/lit/tests/xfail-cl.py | 18 ++++++++++++++++++
5 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/llvm/utils/lit/lit/Test.py b/llvm/utils/lit/lit/Test.py
index 1bd5ba8dc2070..3175be644c265 100644
--- a/llvm/utils/lit/lit/Test.py
+++ b/llvm/utils/lit/lit/Test.py
@@ -246,7 +246,10 @@ def __init__(
# These can optionally be provided by test format handlers,
# and will be honored when the test result is supplied.
self.xfails = []
-
+
+ # Skip this test if it's xfail.
+ self.skip_xfail = False
+
# If true, ignore all items in self.xfails.
self.xfail_not = False
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 73db67aedb739..2c12e9813887f 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -2175,6 +2175,8 @@ def parseIntegratedTestScript(test, additional_parsers=[], require_script=True):
assert parsed["DEFINE:"] == script
assert parsed["REDEFINE:"] == script
test.xfails += parsed["XFAIL:"] or []
+ if test.xfails and test.skip_xfail:
+ return lit.Test.Result(Test.SKIPPED, "skipping XFAIL tests")
test.requires += parsed["REQUIRES:"] or []
test.unsupported += parsed["UNSUPPORTED:"] or []
if parsed["ALLOW_RETRIES:"]:
diff --git a/llvm/utils/lit/lit/cl_arguments.py b/llvm/utils/lit/lit/cl_arguments.py
index 3292554ab5ff7..7cd70937bea82 100644
--- a/llvm/utils/lit/lit/cl_arguments.py
+++ b/llvm/utils/lit/lit/cl_arguments.py
@@ -303,6 +303,12 @@ def parse_args():
help="do not XFAIL tests with paths in the semicolon separated list",
default=os.environ.get("LIT_XFAIL_NOT", ""),
)
+ selection_group.add_argument(
+ "--skip-xfail",
+ help="do not XFAIL tests with paths in the semicolon separated list.",
+ default = False,
+ action="store_true",
+ )
selection_group.add_argument(
"--num-shards",
dest="numShards",
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index 0939838b78ceb..88f560c418e98 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -240,6 +240,8 @@ def mark_xfail(selected_tests, opts):
t.xfails += "*"
if test_file in opts.xfail_not or test_full_name in opts.xfail_not:
t.xfail_not = True
+ if opts.skip_xfail:
+ t.skip_xfail = True
def mark_excluded(discovered_tests, selected_tests):
diff --git a/llvm/utils/lit/tests/xfail-cl.py b/llvm/utils/lit/tests/xfail-cl.py
index ef1bb0414cfea..0e0f671170e21 100644
--- a/llvm/utils/lit/tests/xfail-cl.py
+++ b/llvm/utils/lit/tests/xfail-cl.py
@@ -5,6 +5,12 @@
# RUN: %{inputs}/xfail-cl \
# RUN: | FileCheck --check-prefix=CHECK-FILTER %s
+# RUN: %{lit} --xfail 'false.txt;false2.txt;top-level-suite :: b :: test.txt' \
+# RUN: --skip-xfail \
+# RUN: %{inputs}/xfail-cl \
+# RUN: | FileCheck --check-prefix=CHECK-SKIP %s
+
+
# RUN: env LIT_XFAIL='false.txt;false2.txt;top-level-suite :: b :: test.txt' \
# RUN: LIT_XFAIL_NOT='true-xfail.txt;top-level-suite :: a :: test-xfail.txt' \
# RUN: %{lit} %{inputs}/xfail-cl \
@@ -37,3 +43,15 @@
# CHECK-OVERRIDE: Testing: 1 tests, {{[0-9]*}} workers
# CHECK-OVERRIDE: {{^}}PASS: top-level-suite :: true-xfail.txt
+
+# CHECK-SKIP: Testing: 10 tests, {{[0-9]*}} workers
+# CHECK-SKIP-DAG: {{^}}SKIPPED: top-level-suite :: a :: false.txt
+# CHECK-SKIP-DAG: {{^}}SKIPPED: top-level-suite :: a :: test-xfail.txt
+# CHECK-SKIP-DAG: {{^}}PASS: top-level-suite :: a :: test.txt
+# CHECK-SKIP-DAG: {{^}}SKIPPED: top-level-suite :: b :: false.txt
+# CHECK-SKIP-DAG: {{^}}SKIPPED: top-level-suite :: b :: test-xfail.txt
+# CHECK-SKIP-DAG: {{^}}SKIPPED: top-level-suite :: b :: test.txt
+# CHECK-SKIP-DAG: {{^}}SKIPPED: top-level-suite :: false.txt
+# CHECK-SKIP-DAG: {{^}}SKIPPED: top-level-suite :: false2.txt
+# CHECK-SKIP-DAG: {{^}}SKIPPED: top-level-suite :: true-xfail.txt
+# CHECK-SKIP-DAG: {{^}}PASS: top-level-suite :: true.txt
More information about the llvm-commits
mailing list