Skip to content

Commit 76cb3e9

Browse files
committed
[libc++] Optionally support filecheck-based tests
This patch adds support for filecheck tests in libc++'s test suite. However, it doesn't use LLVM's filecheck program, which requires building a bunch of LLVM utilities. Instead, it installs the Python port of filecheck at https://github.com/AntonLydike/filecheck which supports basically the same functionality. The test suite still works when filecheck is not available, since tests that use filecheck should be guarded on the `has-filecheck` Lit feature. This should make it possible to test several things that were previously impossible to test, especially for specific code generation.
1 parent a98295d commit 76cb3e9

File tree

6 files changed

+39
-1
lines changed

6 files changed

+39
-1
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ jobs:
221221
run: |
222222
python3 -m venv .venv
223223
source .venv/bin/activate
224-
python -m pip install psutil
224+
pip install -r libcxx/test/requirements.txt
225225
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
226226
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
227227
if: always() # Upload artifacts even if the build or test suite fails

libcxx/docs/TestingLibcxx.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ Please see the `Lit Command Guide`_ for more information about LIT.
2323

2424
.. _LIT Command Guide: https://llvm.org/docs/CommandGuide/lit.html
2525

26+
Dependencies
27+
------------
28+
29+
The libc++ test suite has a few optional dependencies. These can be installed
30+
with ``pip install -r libcxx/test/requirements.txt``. Installing these dependencies
31+
will ensure that the maximum number of tests can be run.
32+
2633
Usage
2734
-----
2835

libcxx/test/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# This file defines Python requirements to run the libc++ test suite.
3+
#
4+
filecheck
5+
psutil
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// REQUIRES: has-filecheck
10+
11+
// Make sure that we can use filecheck to write tests when the `has-filecheck`
12+
// Lit feature is defined.
13+
14+
// RUN: echo "hello world" | filecheck %s
15+
// CHECK: hello world

libcxx/utils/ci/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ RUN sudo apt-get update \
111111
xz-utils \
112112
&& sudo rm -rf /var/lib/apt/lists/*
113113

114+
COPY ../../test/requirements.txt .
115+
RUN python3 -m pip install -r requirements.txt
116+
114117
RUN <<EOF
115118
set -e
116119
wget -qO /tmp/ninja.gz https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip

libcxx/utils/libcxx/test/features.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,14 @@ def _mingwSupportsModules(cfg):
355355
name="has-no-zdump",
356356
when=lambda cfg: runScriptExitCode(cfg, ["zdump --version"]) != 0,
357357
),
358+
# Whether the `filecheck` executable is available. Note that this corresponds to
359+
# a Python port of LLVM's FileCheck, not LLVM's actual FileCheck program, since
360+
# that one requires building parts of LLVM that we don't want to build when merely
361+
# testing libc++.
362+
Feature(
363+
name="has-filecheck",
364+
when=lambda cfg: runScriptExitCode(cfg, ["filecheck --version"]) == 0,
365+
),
358366
]
359367

360368
# Deduce and add the test features that that are implied by the #defines in

0 commit comments

Comments
 (0)