Add LIT_UNSUPPORTED support to lit testing#193766
Conversation
Add LIT_UNSUPPORTED support to lit, mirroring the existing LIT_XFAIL implementation. This allows tests to be marked as UNSUPPORTED via command line arguments (--unsupported, --unsupported-not) or environment variables (LIT_UNSUPPORTED, LIT_UNSUPPORTED_NOT). This feature enables users to dynamically mark tests as unsupported without modifying test files, useful for CI/CD pipelines and platform-specific test filtering. Assisted by AI.
|
@llvm/pr-subscribers-testing-tools Author: Lei Huang (lei137) ChangesAdd LIT_UNSUPPORTED support to lit, mirroring the existing LIT_XFAIL This feature enables users to dynamically mark tests as unsupported Assisted by AI. Full diff: https://github.com/llvm/llvm-project/pull/193766.diff 4 Files Affected:
diff --git a/llvm/utils/lit/lit/Test.py b/llvm/utils/lit/lit/Test.py
index daba14a898c4c..6f87ecfc82d15 100644
--- a/llvm/utils/lit/lit/Test.py
+++ b/llvm/utils/lit/lit/Test.py
@@ -262,6 +262,9 @@ def __init__(
# If true, ignore all items in self.xfails.
self.xfail_not = False
+ # If true, ignore all items in self.unsupported.
+ self.unsupported_not = False
+
# A list of conditions that must be satisfied before running the test.
# Each condition is a boolean expression of features. All of them
# must be True for the test to run.
@@ -423,6 +426,9 @@ def getUnsupportedFeatures(self):
Throws ValueError if an UNSUPPORTED line has a syntax error.
"""
+ if self.unsupported_not:
+ return []
+
features = self.config.available_features
try:
diff --git a/llvm/utils/lit/lit/cl_arguments.py b/llvm/utils/lit/lit/cl_arguments.py
index bebde4b762b0e..a2e1d51e7bc83 100644
--- a/llvm/utils/lit/lit/cl_arguments.py
+++ b/llvm/utils/lit/lit/cl_arguments.py
@@ -464,6 +464,20 @@ def parse_args():
default=False,
action="store_true",
)
+ selection_group.add_argument(
+ "--unsupported",
+ metavar="LIST",
+ type=_semicolon_list,
+ help="UNSUPPORTED tests with paths in the semicolon separated list",
+ default=os.environ.get("LIT_UNSUPPORTED", ""),
+ )
+ selection_group.add_argument(
+ "--unsupported-not",
+ metavar="LIST",
+ type=_semicolon_list,
+ help="do not UNSUPPORTED tests with paths in the semicolon separated list",
+ default=os.environ.get("LIT_UNSUPPORTED_NOT", ""),
+ )
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 77b23bf560c6e..4f07cb30b4e5b 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -122,6 +122,7 @@ def main(builtin_params={}):
selected_tests = selected_tests[: opts.max_tests]
mark_xfail(discovered_tests, opts)
+ mark_unsupported(discovered_tests, opts)
mark_excluded(discovered_tests, selected_tests)
@@ -248,6 +249,18 @@ def mark_xfail(selected_tests, opts):
t.exclude_xfail = True
+def mark_unsupported(selected_tests, opts):
+ for t in selected_tests:
+ test_file = os.sep.join(t.path_in_suite)
+ test_full_name = t.getFullName()
+ if test_file in opts.unsupported or test_full_name in opts.unsupported:
+ # Add a special feature that's always present to mark as unsupported
+ t.config.available_features.add("lit-unsupported-marker")
+ t.unsupported.append("lit-unsupported-marker")
+ if test_file in opts.unsupported_not or test_full_name in opts.unsupported_not:
+ t.unsupported_not = True
+
+
def mark_excluded(discovered_tests, selected_tests):
excluded_tests = set(discovered_tests) - set(selected_tests)
result = lit.Test.Result(lit.Test.EXCLUDED)
diff --git a/llvm/utils/lit/tests/unsupported-cl.py b/llvm/utils/lit/tests/unsupported-cl.py
new file mode 100644
index 0000000000000..b654cbccd1abe
--- /dev/null
+++ b/llvm/utils/lit/tests/unsupported-cl.py
@@ -0,0 +1,39 @@
+# Check that marking tests as UNSUPPORTED works via command line or env var.
+
+# RUN: %{lit} --unsupported 'false.txt;false2.txt;top-level-suite :: b :: test.txt' \
+# RUN: --unsupported-not 'true-xfail.txt;top-level-suite :: a :: test-xfail.txt' \
+# RUN: %{inputs}/xfail-cl \
+# RUN: | FileCheck --check-prefix=CHECK-FILTER %s
+
+# RUN: env LIT_UNSUPPORTED='false.txt;false2.txt;top-level-suite :: b :: test.txt' \
+# RUN: LIT_UNSUPPORTED_NOT='true-xfail.txt;top-level-suite :: a :: test-xfail.txt' \
+# RUN: %{lit} %{inputs}/xfail-cl \
+# RUN: | FileCheck --check-prefix=CHECK-FILTER %s
+
+# Check that --unsupported-not and LIT_UNSUPPORTED_NOT always have precedence.
+
+# RUN: env LIT_UNSUPPORTED=true-xfail.txt \
+# RUN: %{lit} --unsupported true-xfail.txt --unsupported-not true-xfail.txt \
+# RUN: --unsupported true-xfail.txt %{inputs}/xfail-cl/true-xfail.txt \
+# RUN: | FileCheck --check-prefix=CHECK-OVERRIDE %s
+
+# RUN: env LIT_UNSUPPORTED_NOT=true-xfail.txt LIT_UNSUPPORTED=true-xfail.txt \
+# RUN: %{lit} --unsupported true-xfail.txt %{inputs}/xfail-cl/true-xfail.txt \
+# RUN: | FileCheck --check-prefix=CHECK-OVERRIDE %s
+
+# END.
+
+# CHECK-FILTER: Testing: 11 tests, {{[0-9]*}} workers
+# CHECK-FILTER-DAG: {{^}}PASS: top-level-suite :: a :: test.txt
+# CHECK-FILTER-DAG: {{^}}UNSUPPORTED: top-level-suite :: b :: test.txt
+# CHECK-FILTER-DAG: {{^}}UNSUPPORTED: top-level-suite :: a :: false.txt
+# CHECK-FILTER-DAG: {{^}}UNSUPPORTED: top-level-suite :: b :: false.txt
+# CHECK-FILTER-DAG: {{^}}UNSUPPORTED: top-level-suite :: false.txt
+# CHECK-FILTER-DAG: {{^}}UNSUPPORTED: top-level-suite :: false2.txt
+# CHECK-FILTER-DAG: {{^}}PASS: top-level-suite :: true.txt
+# CHECK-FILTER-DAG: {{^}}PASS: top-level-suite :: true-xfail.txt
+# CHECK-FILTER-DAG: {{^}}PASS: top-level-suite :: a :: test-xfail.txt
+# CHECK-FILTER-DAG: {{^}}UNSUPPORTED: top-level-suite :: b :: test-xfail.txt
+
+# CHECK-OVERRIDE: Testing: 1 tests, {{[0-9]*}} workers
+# CHECK-OVERRIDE: {{^}}PASS: top-level-suite :: true-xfail.txt
|
🐧 Linux x64 Test Results
Failed Tests(click on a test name to see its output) litlit.lit/unsupported-cl.pyIf these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
🪟 Windows x64 Test Results
Failed Tests(click on a test name to see its output) litlit.lit/unsupported-cl.pyIf these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
Add LIT_UNSUPPORTED support to lit, mirroring the existing LIT_XFAIL
implementation. This allows tests to be marked as UNSUPPORTED via
command line arguments (--unsupported, --unsupported-not) or environment
variables (LIT_UNSUPPORTED, LIT_UNSUPPORTED_NOT).
This feature enables users to dynamically mark tests as unsupported
without modifying test files, useful for CI/CD pipelines and
platform-specific test filtering.
Assisted by AI.