diff --git a/clang-tools-extra/clangd/test/CMakeLists.txt b/clang-tools-extra/clangd/test/CMakeLists.txt --- a/clang-tools-extra/clangd/test/CMakeLists.txt +++ b/clang-tools-extra/clangd/test/CMakeLists.txt @@ -11,8 +11,8 @@ set(CLANGD_TEST_DEPS clangd ClangdTests - # No tests for these, but we should still make sure they build. clangd-indexer + # No tests for it, but we should still make sure they build. dexp ) diff --git a/clang-tools-extra/clangd/test/Inputs/remote-index/Header.h b/clang-tools-extra/clangd/test/Inputs/remote-index/Header.h new file mode 100644 --- /dev/null +++ b/clang-tools-extra/clangd/test/Inputs/remote-index/Header.h @@ -0,0 +1,10 @@ +namespace clang { +namespace clangd { +namespace remote { +int getFoo(bool Argument); +char Character; +} // namespace remote +} // namespace clangd +} // namespace clang + +namespace llvm {} // namespace llvm diff --git a/clang-tools-extra/clangd/test/Inputs/remote-index/Source.cpp b/clang-tools-extra/clangd/test/Inputs/remote-index/Source.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/clangd/test/Inputs/remote-index/Source.cpp @@ -0,0 +1,3 @@ +#include "Header.h" + +namespace {} // namespace diff --git a/clang-tools-extra/clangd/test/lit.cfg.py b/clang-tools-extra/clangd/test/lit.cfg.py --- a/clang-tools-extra/clangd/test/lit.cfg.py +++ b/clang-tools-extra/clangd/test/lit.cfg.py @@ -14,7 +14,7 @@ # Used to enable tests based on the required targets. Can be queried with e.g. # REQUIRES: x86-registered-target def calculate_arch_features(arch_string): - return [arch.lower() + '-registered-target' for arch in arch_string.split()] + return [arch.lower() + '-registered-target' for arch in arch_string.split()] lit.llvm.llvm_config.feature_config([('--targets-built', @@ -25,4 +25,7 @@ config.clangd_binary_dir + "/benchmarks")) if config.clangd_build_xpc: - config.available_features.add('clangd-xpc-support') + config.available_features.add('clangd-xpc-support') + +if config.clangd_enable_remote: + config.available_features.add('clangd-remote-index') diff --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in b/clang-tools-extra/clangd/test/lit.site.cfg.py.in --- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in +++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in @@ -23,6 +23,7 @@ config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.." config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.." config.clangd_build_xpc = @CLANGD_BUILD_XPC@ +config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@ # Delegate logic to lit.cfg.py. lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") diff --git a/clang-tools-extra/clangd/test/remote-index/pipeline.test b/clang-tools-extra/clangd/test/remote-index/pipeline.test new file mode 100644 --- /dev/null +++ b/clang-tools-extra/clangd/test/remote-index/pipeline.test @@ -0,0 +1,47 @@ +# FIXME: Unsupported on Windows because of POSIX features (export, &, kill). +# UNSUPPORTED: darwin, windows +# RUN: rm -rf %/t +# RUN: export PROJECT_ROOT=%/S/../Inputs/remote-index/ +# RUN: clangd-indexer $PROJECT_ROOT/Source.cpp > %t.in.dex +# FIXME: Check that default address (0.0.0.0:50051) is available. +# RUN: export SERVER_ADDRESS="0.0.0.0:50051" +# RUN: clangd-index-server --server-address=$SERVER_ADDRESS %t.in.dex $PROJECT_ROOT & export PID=$! +# RUN: sleep 2 +# RUN: clangd --remote-index-address=$SERVER_ADDRESS --project-root=$PROJECT_ROOT --lit-test < %s | FileCheck %s +# RUN: kill -9 $PID +# REQUIRES: clangd-remote-index + +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +# CHECK: "id": 0, +# CHECK-NEXT: "jsonrpc": "2.0", +--- +{"jsonrpc":"2.0","id":1,"method":"workspace/symbol","params":{"query":"Character"}} +# CHECK: "id": 1, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": [ +# CHECK-NEXT: { +# CHECK-NEXT: "containerName": "clang::clangd::remote", +# CHECK-NEXT: "kind": 13, +# CHECK-NEXT: "location": { +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": {{.*}}, +# CHECK-NEXT: "line": {{.*}} +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": {{.*}}, +# CHECK-NEXT: "line": {{.*}} +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "uri": "file://{{.*}}/Header.h" +# CHECK-NEXT: }, +# CHECK-NEXT: "name": "Character", +# CHECK-NEXT: "score": {{.*}} +# CHECK-NEXT: } +# CHECK-NEXT: ] +# CHECK-NEXT:} +--- +{"jsonrpc":"2.0","id":4,"method":"shutdown"} +--- +{"jsonrpc":"2.0","method":"exit"} +---