This provides optional lit-based test execution for the LLVM Libc tests, alongside the existing CMake-based test execution. Usage: ninja -C build check-libc-lit cd build && bin/llvm-lit libc/test/src/ Partially addresses [#118694](https://github.com/llvm/llvm-project/issues/118694). A future PR once this lands will flip the default (per suggestion in the RFC)
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
@LIT_SITE_CFG_IN_HEADER@
|
|
|
|
import os
|
|
import site
|
|
|
|
# Configuration values from CMake
|
|
config.llvm_tools_dir = lit_config.substitute(path(r"@LLVM_TOOLS_DIR@"))
|
|
config.libc_src_root = path(r"@LIBC_SOURCE_DIR@")
|
|
config.libc_obj_root = path(r"@LIBC_BUILD_DIR@")
|
|
config.libc_test_cmd = "@LIBC_TEST_CMD@"
|
|
|
|
# Add libc's utils directory to the path so we can import the test format.
|
|
site.addsitedir(os.path.join(config.libc_src_root, "utils"))
|
|
import libctest
|
|
|
|
# name: The name of this test suite.
|
|
config.name = "libc"
|
|
|
|
# testFormat: Use libc's custom test format that discovers pre-built
|
|
# test executables (Libc*Tests) in the build directory.
|
|
config.test_format = libctest.LibcTest()
|
|
|
|
# excludes: A list of directories to exclude from the testsuite.
|
|
config.excludes = ["Inputs", "CMakeLists.txt", "README.txt", "LICENSE.txt", "UnitTest"]
|
|
|
|
# test_source_root: The root path where tests are located.
|
|
# test_exec_root: The root path where test executables are built.
|
|
# Set both to the build directory so ExecutableTest finds executables correctly.
|
|
config.test_exec_root = os.path.join(config.libc_obj_root, "test")
|
|
config.test_source_root = config.test_exec_root
|
|
|
|
# Add tool directories to PATH (in case we add FileCheck tests later).
|
|
if hasattr(config, "llvm_tools_dir") and config.llvm_tools_dir:
|
|
config.environment["PATH"] = os.path.pathsep.join(
|
|
[config.llvm_tools_dir, config.environment.get("PATH", "")]
|
|
)
|
|
|