Skip to content

Commit 355bf7c

Browse files
committed
[lit] Extend --xfail/LIT_XFAIL to take full test name
The new documentation entry gives an example use case from libomptarget. Reviewed By: yln, jhenderson, davezarzycki Differential Revision: https://reviews.llvm.org/D105208
1 parent 0516f49 commit 355bf7c

File tree

9 files changed

+59
-9
lines changed

9 files changed

+59
-9
lines changed

llvm/docs/CommandGuide/lit.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,31 @@ The timing data is stored in the `test_exec_root` in a file named
239239
this option, which is especially useful in environments where the call to
240240
``lit`` is issued indirectly.
241241

242+
A test name can specified as a file name relative to the test suite directory.
243+
For example:
244+
245+
.. code-block:: none
246+
247+
LIT_XFAIL="affinity/kmp-hw-subset.c;offloading/memory_manager.cpp"
248+
249+
In this case, all of the following tests are treated as ``XFAIL``:
250+
251+
.. code-block:: none
252+
253+
libomp :: affinity/kmp-hw-subset.c
254+
libomptarget :: nvptx64-nvidia-cuda :: offloading/memory_manager.cpp
255+
libomptarget :: x86_64-pc-linux-gnu :: offloading/memory_manager.cpp
256+
257+
Alternatively, a test name can be specified as the full test name
258+
reported in LIT output. For example, we can adjust the previous
259+
example not to treat the ``nvptx64-nvidia-cuda`` version of
260+
``offloading/memory_manager.cpp`` as XFAIL:
261+
262+
.. code-block:: none
263+
264+
LIT_XFAIL="affinity/kmp-hw-subset.c;libomptarget :: x86_64-pc-linux-gnu :: offloading/memory_manager.cpp"
265+
266+
242267
ADDITIONAL OPTIONS
243268
------------------
244269

llvm/utils/lit/lit/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ def filter_by_shard(tests, run, shards, lit_config):
193193

194194
def mark_xfail(selected_tests, opts):
195195
for t in selected_tests:
196-
if os.sep.join(t.path_in_suite) in opts.xfail:
196+
test_file = os.sep.join(t.path_in_suite)
197+
test_full_name = t.getFullName()
198+
if test_file in opts.xfail or test_full_name in opts.xfail:
197199
t.xfails += '*'
198200

199201
def mark_excluded(discovered_tests, selected_tests):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# RUN: false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import lit.formats
2+
config.name = 'top-level-suite :: a'
3+
config.suffixes = ['.txt']
4+
config.test_format = lit.formats.ShTest()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# RUN: true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# RUN: false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import lit.formats
2+
config.name = 'top-level-suite :: b'
3+
config.suffixes = ['.txt']
4+
config.test_format = lit.formats.ShTest()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# RUN: false

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
# Check that regex-XFAILing works and can be configured via env var.
2-
#
3-
# RUN: %{lit} --xfail 'false.txt;false2.txt' %{inputs}/xfail-cl | FileCheck --check-prefix=CHECK-FILTER %s
4-
# RUN: env LIT_XFAIL='false.txt;false2.txt' %{lit} %{inputs}/xfail-cl | FileCheck --check-prefix=CHECK-FILTER %s
1+
# Check that XFAILing works via command line or env var.
2+
3+
# RUN: %{lit} --xfail 'false.txt;false2.txt;top-level-suite :: b :: test.txt' \
4+
# RUN: %{inputs}/xfail-cl \
5+
# RUN: | FileCheck --check-prefix=CHECK-FILTER %s
6+
7+
# RUN: env LIT_XFAIL='false.txt;false2.txt;top-level-suite :: b :: test.txt' \
8+
# RUN: %{lit} %{inputs}/xfail-cl \
9+
# RUN: | FileCheck --check-prefix=CHECK-FILTER %s
10+
511
# END.
6-
# CHECK-FILTER: Testing: 3 tests, {{[1-3]}} workers
7-
# CHECK-FILTER-DAG: XFAIL: top-level-suite :: false.txt
8-
# CHECK-FILTER-DAG: XFAIL: top-level-suite :: false2.txt
9-
# CHECK-FILTER-DAG: PASS: top-level-suite :: true.txt
12+
13+
# CHECK-FILTER: Testing: 7 tests, {{[1-7]}} workers
14+
# CHECK-FILTER-DAG: {{^}}PASS: top-level-suite :: a :: test.txt
15+
# CHECK-FILTER-DAG: {{^}}XFAIL: top-level-suite :: b :: test.txt
16+
# CHECK-FILTER-DAG: {{^}}XFAIL: top-level-suite :: a :: false.txt
17+
# CHECK-FILTER-DAG: {{^}}XFAIL: top-level-suite :: b :: false.txt
18+
# CHECK-FILTER-DAG: {{^}}XFAIL: top-level-suite :: false.txt
19+
# CHECK-FILTER-DAG: {{^}}XFAIL: top-level-suite :: false2.txt
20+
# CHECK-FILTER-DAG: {{^}}PASS: top-level-suite :: true.txt

0 commit comments

Comments
 (0)