Skip to content

Commit 1f7ad82

Browse files
boomanaiden154augusto2112
authored andcommitted
Reapply "[clangd] Make lit tests work with the internal shell" (llvm#169972)
This reverts commit bd04ef6. This reapply fixes the broken case where we would fail at CMake configuration time if LLVM_INCLUDE_BENCHMARKS was explicitly turned off.
1 parent e482da3 commit 1f7ad82

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

clang-tools-extra/clangd/test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ set(CLANGD_TEST_DEPS
55
split-file
66
)
77

8+
if (LLVM_INCLUDE_BENCHMARKS)
9+
list(APPEND CLANGD_TEST_DEPS IndexBenchmark)
10+
endif()
11+
812
if(CLANGD_BUILD_XPC)
913
list(APPEND CLANGD_TEST_DEPS clangd-xpc-test-client)
1014
list(APPEND CLANGD_TEST_DEPS ClangdXpcUnitTests)

clang-tools-extra/clangd/test/include-cleaner-batch-fix.test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
# RUN: cp -r %S/Inputs/include-cleaner %t/include
88
# RUN: echo '-I%t/include' > %t/compile_flags.txt
99
# Create a config file enabling include-cleaner features.
10-
# RUN: echo $'Diagnostics:\n UnusedIncludes: Strict\n MissingIncludes: Strict' >> %t/clangd/config.yaml
10+
# RUN: echo 'Diagnostics:' > %t/clangd/config.yaml
11+
# RUN: echo ' UnusedIncludes: Strict' >> %t/clangd/config.yaml
12+
# RUN: echo ' MissingIncludes: Strict' >> %t/clangd/config.yaml
1113

1214
# RUN: env XDG_CONFIG_HOME=%t clangd -lit-test -enable-config --compile-commands-dir=%t < %s | FileCheck -strict-whitespace %s
1315
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"workspace":{"workspaceEdit":{"documentChanges":true, "changeAnnotationSupport":{"groupsOnLabel":true}}}},"trace":"off"}}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
# Paths are not constructed correctly for the test to run on Windows.
2+
# UNSUPPORTED: system-windows
3+
# REQUIRES: have-benchmarks
14
# RUN: clangd-indexer %p/Inputs/BenchmarkSource.cpp -- -I%p/Inputs > %t.index
2-
# FIXME: By default, benchmarks are excluded from the list of default targets hence not built. Find a way to depend on benchmarks to run the next command.
3-
# REQUIRES: shell
4-
# RUN: if [ -f %clangd-benchmark-dir/IndexBenchmark ]; then %clangd-benchmark-dir/IndexBenchmark %t.index %p/Inputs/requests.json --benchmark_min_time=0.01 ; fi
5+
# RUN: %clangd-benchmark-dir/IndexBenchmark %t.index %p/Inputs/requests.json --benchmark_min_time=0.01
56
# Pass invalid JSON file and check that IndexBenchmark fails to parse it.
6-
# RUN: if [ -f %clangd-benchmark-dir/IndexBenchmark ]; then not %clangd-benchmark-dir/IndexBenchmark %t.index %t --benchmark_min_time=0.01 ; fi
7+
# RUN: not %clangd-benchmark-dir/IndexBenchmark %t.index %t --benchmark_min_time=0.01

clang-tools-extra/clangd/test/lit.cfg.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import lit.llvm
2+
import lit.util
23

34
lit.llvm.initialize(lit_config, config)
45
lit.llvm.llvm_config.clang_setup()
@@ -37,6 +38,9 @@ def calculate_arch_features(arch_string):
3738
if config.have_zlib:
3839
config.available_features.add("zlib")
3940

41+
if lit.util.pythonize_bool(config.have_benchmarks):
42+
config.available_features.add("have-benchmarks")
43+
4044
# It is not realistically possible to account for all options that could
4145
# possibly be present in system and user configuration files, so disable
4246
# default configs for the test runs.

clang-tools-extra/clangd/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ config.clangd_build_dexp = @CLANGD_BUILD_DEXP@
1919
config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
2020
config.clangd_tidy_checks = @CLANGD_TIDY_CHECKS@
2121
config.have_zlib = @LLVM_ENABLE_ZLIB@
22+
config.have_benchmarks = "@LLVM_INCLUDE_BENCHMARKS@"
2223

2324
# Delegate logic to lit.cfg.py.
2425
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")

clang-tools-extra/clangd/test/system-include-extractor.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
# Create a bin directory to store the mock-driver and add it to the path
77
# RUN: mkdir -p %t.dir/bin
8-
# RUN: export PATH=%t.dir/bin:$PATH
8+
# RUN: %python -c "print(__import__('os').environ['PATH'])" > %t.path
9+
# RUN: export PATH=%t.dir/bin:%{readfile:%t.path}
910
# Generate a mock-driver that will print %temp_dir%/my/dir and
1011
# %temp_dir%/my/dir2 as include search paths.
1112
# RUN: echo '#!/bin/sh' >> %t.dir/bin/my_driver.sh

0 commit comments

Comments
 (0)