kbobyrev updated this revision to Diff 301303.
kbobyrev added a comment.

Don't change the existing Python formatting.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90291/new/

https://reviews.llvm.org/D90291

Files:
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/Inputs/remote-index/Header.h
  clang-tools-extra/clangd/test/Inputs/remote-index/Source.cpp
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang-tools-extra/clangd/test/remote-index/pipeline.test
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===================================================================
--- /dev/null
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+#
+#===- pipeline_helper.py - Remote Index pipeline Helper *- python ------*--===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===-----------------------------------------------------------------------===#
+
+import argparse
+import os
+import subprocess
+import time
+
+
+def main():
+  parser = argparse.ArgumentParser()
+  parser.add_argument('--input-file-name', required=True)
+  parser.add_argument('--server-address', required=True)
+  parser.add_argument('--test-directory', required=True)
+  parser.add_argument('--index-file', required=True)
+
+  args = parser.parse_args()
+
+  project_root = os.path.join(args.test_directory, '..', 'Inputs',
+                              'remote-index')
+
+  index_server_process = subprocess.Popen([
+      'clangd-index-server', '--server-address=' + args.server_address,
+      os.path.abspath(args.index_file),
+      os.path.abspath(project_root)
+  ])
+
+  # Wait for the server to warm-up.
+  time.sleep(2)
+
+  in_file = open(args.input_file_name)
+
+  subprocess.Popen([
+      'clangd', '--remote-index-address=' + args.server_address,
+      '--project-root=' + os.path.abspath(project_root), '--lit-test', '--sync'
+  ],
+                   stdin=in_file)
+
+  # Keep the server alive until request is complete.
+  time.sleep(1)
+
+  os.kill(index_server_process.pid, 9)
+
+
+if __name__ == '__main__':
+  main()
Index: clang-tools-extra/clangd/test/remote-index/pipeline.test
===================================================================
--- /dev/null
+++ clang-tools-extra/clangd/test/remote-index/pipeline.test
@@ -0,0 +1,39 @@
+# RUN: rm -rf %/t
+# RUN: clangd-indexer %/S/../Inputs/remote-index/Source.cpp > %t.in.dex
+# RUN: python %/S/pipeline_helper.py --input-file-name=%s --server-address=0.0.0.0:50051 --test-directory=%/S --index-file=%t.in.dex | FileCheck %s
+# 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"}
+---
Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===================================================================
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ 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")
Index: clang-tools-extra/clangd/test/lit.cfg.py
===================================================================
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -26,3 +26,6 @@
 
 if config.clangd_build_xpc:
   config.available_features.add('clangd-xpc-support')
+
+if config.clangd_enable_remote:
+  config.available_features.add('clangd-remote-index')
Index: clang-tools-extra/clangd/test/Inputs/remote-index/Source.cpp
===================================================================
--- /dev/null
+++ clang-tools-extra/clangd/test/Inputs/remote-index/Source.cpp
@@ -0,0 +1,3 @@
+#include "Header.h"
+
+namespace {} // namespace
Index: clang-tools-extra/clangd/test/Inputs/remote-index/Header.h
===================================================================
--- /dev/null
+++ 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
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===================================================================
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ 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
   )
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to