Skip to content

Commit bb48391

Browse files
committed
[lit] Add an option to read an xfail list from a file
The `--xfail` and `--xfail-not` lit options allow a list of tests to be marked as expected to fail/pass on the command line. We've found this to be useful in CI to temporarily change the state of a test without making changes to the test sources, while a more appropriate fix is investigated. However, we've encountered cases where the list needs to be quite long (100+ tests), which leads to some very long command strings. This patch extends the existing options with additional ones, `--xfail-from-file` and `--xfail-not-from-file` that will instead read the list from a file instead of directly from the command line. The underlying functionality remains exactly the same, with only an alternative source for the lists.
1 parent 0590c9e commit bb48391

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

llvm/docs/CommandGuide/lit.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ The timing data is stored in the `test_exec_root` in a file named
346346
347347
LIT_XFAIL="affinity/kmp-hw-subset.c;libomptarget :: x86_64-pc-linux-gnu :: offloading/memory_manager.cpp"
348348
349+
.. option:: --xfail-from-file PATH
350+
351+
Read a line separated list of tests from a file to be used by :option:`--xfail`.
352+
349353
.. option:: --xfail-not LIST
350354

351355
Do not treat the specified tests as ``XFAIL``. The environment variable
@@ -356,6 +360,10 @@ The timing data is stored in the `test_exec_root` in a file named
356360
primary purpose is to suppress an ``XPASS`` result without modifying a test
357361
case that uses the ``XFAIL`` directive.
358362

363+
.. option:: --xfail-not-from-file PATH
364+
365+
Read a line separated list of tests from a file to be used by :option:`--xfail-not`.
366+
359367
.. option:: --exclude-xfail
360368

361369
``XFAIL`` tests won't be run, unless they are listed in the ``--xfail-not``

llvm/utils/lit/lit/cl_arguments.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,25 @@ def parse_args():
309309
help="XFAIL tests with paths in the semicolon separated list",
310310
default=os.environ.get("LIT_XFAIL", ""),
311311
)
312+
selection_group.add_argument(
313+
"--xfail-from-file",
314+
metavar="PATH",
315+
help="XFAIL tests with paths in the line separated list contained in "
316+
"the specified file",
317+
)
312318
selection_group.add_argument(
313319
"--xfail-not",
314320
metavar="LIST",
315321
type=_semicolon_list,
316322
help="do not XFAIL tests with paths in the semicolon separated list",
317323
default=os.environ.get("LIT_XFAIL_NOT", ""),
318324
)
325+
selection_group.add_argument(
326+
"--xfail-not-from-file",
327+
metavar="PATH",
328+
help="do not XFAIL tests with paths in the line separated list "
329+
"contained in the specified file",
330+
)
319331
selection_group.add_argument(
320332
"--exclude-xfail",
321333
help="exclude XFAIL tests (unless they are in the --xfail-not list). "
@@ -396,6 +408,13 @@ def parse_args():
396408
for report in opts.reports:
397409
report.use_unique_output_file_name = opts.use_unique_output_file_name
398410

411+
if opts.xfail_from_file:
412+
with open(opts.xfail_from_file, "r", encoding="utf-8") as f:
413+
opts.xfail.extend(f.read().splitlines())
414+
if opts.xfail_not_from_file:
415+
with open(opts.xfail_not_from_file, "r", encoding="utf-8") as f:
416+
opts.xfail_not.extend(f.read().splitlines())
417+
399418
return opts
400419

401420

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
true-xfail.txt
2+
top-level-suite :: a :: test-xfail.txt
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
false.txt
2+
false2.txt
3+
top-level-suite :: b :: test.txt

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
# RUN: %{inputs}/xfail-cl \
1717
# RUN: | FileCheck --check-prefixes=CHECK-EXCLUDED,CHECK-EXCLUDED-OVERRIDE %s
1818

19+
# RUN: %{lit} --xfail-from-file %{inputs}/xfail-cl/xfail.list \
20+
# RUN: --xfail-not-from-file %{inputs}/xfail-cl/xfail-not.list \
21+
# RUN: %{inputs}/xfail-cl \
22+
# RUN: | FileCheck --check-prefix=CHECK-FILTER %s
1923

2024
# RUN: env LIT_XFAIL='false.txt;false2.txt;top-level-suite :: b :: test.txt' \
2125
# RUN: LIT_XFAIL_NOT='true-xfail.txt;top-level-suite :: a :: test-xfail.txt' \

0 commit comments

Comments
 (0)