Skip to content

Commit 31d0290

Browse files
[clangd] Make lit tests work with the internal shell
This makes all of the clangd tests work with the internal shell. Modifications needed for each test are as follows: 1. system-include-extractor.test was using variable expansion which is not supported in the internal shell. This patch rewrites it to use the readfile mechanism along with python. This isn't super pretty but is readily understandable and there are only two tests across the monorepo that use this construction, so making it prettier is hard to justify. 2. include-cleaner-batch-fix.test - Was using $'' construction to create new lines in a string. Simply replace it with multiple echo commands to be canonical with the rest of the repository. 3. index-tools.test - Just add IndexBenchmark to the clangd test depends, so the test now just works unconditionally. This should significantly increase test coverage at little cost. Pull Request: llvm#169539
1 parent 6a6b99a commit 31d0290

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set(CLANGD_TEST_DEPS
33
ClangdTests
44
clangd-indexer
55
split-file
6+
IndexBenchmark
67
)
78

89
if(CLANGD_BUILD_XPC)

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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# 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
2+
# RUN: %clangd-benchmark-dir/IndexBenchmark %t.index %p/Inputs/requests.json --benchmark_min_time=0.01
53
# 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
4+
# RUN: not %clangd-benchmark-dir/IndexBenchmark %t.index %t --benchmark_min_time=0.01

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)