clang-tools 22.0.0git
test/lit.cfg.py
Go to the documentation of this file.
1import os
2
3import lit.llvm
4import lit.util
5
6lit.llvm.initialize(lit_config, config)
7lit.llvm.llvm_config.clang_setup()
8lit.llvm.llvm_config.use_default_substitutions()
9
10# TODO: Consolidate the logic for turning on the internal shell by default for all LLVM test suites.
11# See https://github.com/llvm/llvm-project/issues/106636 for more details.
12#
13# We prefer the lit internal shell which provides a better user experience on failures
14# and is faster unless the user explicitly disables it with LIT_USE_INTERNAL_SHELL=0
15# env var.
16use_lit_shell = True
17lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
18if lit_shell_env:
19 use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
20
21config.name = "Clangd"
22config.suffixes = [".test"]
23config.excludes = ["Inputs"]
24config.test_format = lit.formats.ShTest(not use_lit_shell)
25config.test_source_root = config.clangd_source_dir + "/test"
26config.test_exec_root = config.clangd_binary_dir + "/test"
27
28
29# Used to enable tests based on the required targets. Can be queried with e.g.
30# REQUIRES: x86-registered-target
31def calculate_arch_features(arch_string):
32 return [arch.lower() + "-registered-target" for arch in arch_string.split()]
33
34
35lit.llvm.llvm_config.feature_config([("--targets-built", calculate_arch_features)])
36
37# Clangd-specific lit environment.
38config.substitutions.append(
39 ("%clangd-benchmark-dir", config.clangd_binary_dir + "/benchmarks")
40)
41
42if config.clangd_build_xpc:
43 config.available_features.add("clangd-xpc-support")
44
45if config.clangd_enable_remote:
46 config.available_features.add("clangd-remote-index")
47
48if config.clangd_tidy_checks:
49 config.available_features.add("clangd-tidy-checks")
50
51if config.have_zlib:
52 config.available_features.add("zlib")
53
54if lit.util.pythonize_bool(config.have_benchmarks):
55 config.available_features.add("have-benchmarks")
56
57# It is not realistically possible to account for all options that could
58# possibly be present in system and user configuration files, so disable
59# default configs for the test runs.
60config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
calculate_arch_features(arch_string)