Skip to content

Commit b383efc

Browse files
authored
[lit] Optionally exclude xfail tests (#151191)
See the related issue. We want to set up a build bot where `opt` runs with `-enable-profcheck`, which inserts `MD_prof` before running the rest of the pipeline requested from `opt`, and then validates resulting profile information (more info in the RFC linked by the aforementioned issue) In that setup, we will also ignore `FileCheck`: while the profile info inserted is, currently, equivalent to the profile info a pass would observe via `BranchProbabilityInfo`/`BlockFrequencyInfo`, (1) we may want to change that, and (2) some tests are quite sensitive to the output IR, and break if, for instance, extra metadata is present (which it would be due to `-enable-profcheck`). Since we're just interested in profile consistency on the upcoming bot, ignoring `FileCheck` is simpler and sufficient. However, this has the effect of passing XFAIL tests. Rather than listing them all, the alternative is to just exclude XFAIL tests. This PR adds support for that by introducing a `--exclude-xfail` option to `llvm-lit`. Issue #147390
1 parent 506834d commit b383efc

File tree

7 files changed

+51
-1
lines changed

7 files changed

+51
-1
lines changed

llvm/docs/CommandGuide/lit.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ The timing data is stored in the `test_exec_root` in a file named
356356
primary purpose is to suppress an ``XPASS`` result without modifying a test
357357
case that uses the ``XFAIL`` directive.
358358

359+
.. option:: --exclude-xfail
360+
361+
``XFAIL`` tests won't be run, unless they are listed in the ``--xfail-not``
362+
(or ``LIT_XFAIL_NOT``) lists.
363+
359364
.. option:: --num-shards M
360365

361366
Divide the set of selected tests into ``M`` equal-sized subsets or

llvm/utils/lit/lit/Test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ def __init__(
247247
# and will be honored when the test result is supplied.
248248
self.xfails = []
249249

250+
# Exclude this test if it's xfail.
251+
self.exclude_xfail = False
252+
250253
# If true, ignore all items in self.xfails.
251254
self.xfail_not = False
252255

llvm/utils/lit/lit/TestRunner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,8 @@ def parseIntegratedTestScript(test, additional_parsers=[], require_script=True):
21752175
assert parsed["DEFINE:"] == script
21762176
assert parsed["REDEFINE:"] == script
21772177
test.xfails += parsed["XFAIL:"] or []
2178+
if test.exclude_xfail and test.isExpectedToFail():
2179+
return lit.Test.Result(Test.EXCLUDED, "excluding XFAIL tests")
21782180
test.requires += parsed["REQUIRES:"] or []
21792181
test.unsupported += parsed["UNSUPPORTED:"] or []
21802182
if parsed["ALLOW_RETRIES:"]:

llvm/utils/lit/lit/cl_arguments.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ def parse_args():
303303
help="do not XFAIL tests with paths in the semicolon separated list",
304304
default=os.environ.get("LIT_XFAIL_NOT", ""),
305305
)
306+
selection_group.add_argument(
307+
"--exclude-xfail",
308+
help="exclude XFAIL tests (unless they are in the --xfail-not list). "
309+
"Note: This option is implemented in "
310+
"lit.TestRunner.parseIntegratedTestScript and so will have no effect on "
311+
"test formats that do not call that and do not implement the option "
312+
"separately.",
313+
default=False,
314+
action="store_true",
315+
)
306316
selection_group.add_argument(
307317
"--num-shards",
308318
dest="numShards",

llvm/utils/lit/lit/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ def mark_xfail(selected_tests, opts):
240240
t.xfails += "*"
241241
if test_file in opts.xfail_not or test_full_name in opts.xfail_not:
242242
t.xfail_not = True
243+
if opts.exclude_xfail:
244+
t.exclude_xfail = True
243245

244246

245247
def mark_excluded(discovered_tests, selected_tests):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# XFAIL: this-does-not-exist
2+
# RUN: true

llvm/utils/lit/tests/xfail-cl.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
# RUN: %{inputs}/xfail-cl \
66
# RUN: | FileCheck --check-prefix=CHECK-FILTER %s
77

8+
# RUN: %{lit} --xfail 'false.txt;false2.txt;top-level-suite :: b :: test.txt' \
9+
# RUN: --exclude-xfail \
10+
# RUN: %{inputs}/xfail-cl \
11+
# RUN: | FileCheck --check-prefixes=CHECK-EXCLUDED,CHECK-EXCLUDED-NOOVERRIDE %s
12+
13+
# RUN: %{lit} --xfail 'false.txt;false2.txt;top-level-suite :: b :: test.txt' \
14+
# RUN: --xfail-not 'true-xfail.txt' \
15+
# RUN: --exclude-xfail \
16+
# RUN: %{inputs}/xfail-cl \
17+
# RUN: | FileCheck --check-prefixes=CHECK-EXCLUDED,CHECK-EXCLUDED-OVERRIDE %s
18+
19+
820
# RUN: env LIT_XFAIL='false.txt;false2.txt;top-level-suite :: b :: test.txt' \
921
# RUN: LIT_XFAIL_NOT='true-xfail.txt;top-level-suite :: a :: test-xfail.txt' \
1022
# RUN: %{lit} %{inputs}/xfail-cl \
@@ -23,7 +35,7 @@
2335

2436
# END.
2537

26-
# CHECK-FILTER: Testing: 10 tests, {{[0-9]*}} workers
38+
# CHECK-FILTER: Testing: 11 tests, {{[0-9]*}} workers
2739
# CHECK-FILTER-DAG: {{^}}PASS: top-level-suite :: a :: test.txt
2840
# CHECK-FILTER-DAG: {{^}}XFAIL: top-level-suite :: b :: test.txt
2941
# CHECK-FILTER-DAG: {{^}}XFAIL: top-level-suite :: a :: false.txt
@@ -37,3 +49,17 @@
3749

3850
# CHECK-OVERRIDE: Testing: 1 tests, {{[0-9]*}} workers
3951
# CHECK-OVERRIDE: {{^}}PASS: top-level-suite :: true-xfail.txt
52+
53+
# CHECK-EXCLUDED: Testing: 11 tests, {{[0-9]*}} workers
54+
# CHECK-EXCLUDED-DAG: {{^}}EXCLUDED: top-level-suite :: a :: false.txt
55+
# CHECK-EXCLUDED-DAG: {{^}}EXCLUDED: top-level-suite :: a :: test-xfail.txt
56+
# CHECK-EXCLUDED-DAG: {{^}}PASS: top-level-suite :: a :: test.txt
57+
# CHECK-EXCLUDED-DAG: {{^}}EXCLUDED: top-level-suite :: b :: false.txt
58+
# CHECK-EXCLUDED-DAG: {{^}}EXCLUDED: top-level-suite :: b :: test-xfail.txt
59+
# CHECK-EXCLUDED-DAG: {{^}}EXCLUDED: top-level-suite :: b :: test.txt
60+
# CHECK-EXCLUDED-DAG: {{^}}EXCLUDED: top-level-suite :: false.txt
61+
# CHECK-EXCLUDED-DAG: {{^}}EXCLUDED: top-level-suite :: false2.txt
62+
# CHECK-EXCLUDED-DAG: {{^}}PASS: top-level-suite :: true-xfail-conditionally.txt
63+
# CHECK-EXCLUDED-NOOVERRIDE-DAG: {{^}}EXCLUDED: top-level-suite :: true-xfail.txt
64+
# CHECK-EXCLUDED-OVERRIDE-DAG: {{^}}PASS: top-level-suite :: true-xfail.txt
65+
# CHECK-EXCLUDED-DAG: {{^}}PASS: top-level-suite :: true.txt

0 commit comments

Comments
 (0)