[PATCH] D90590: [clangd] Improve remote-index test

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 01:57:47 PST 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd0beda1b6661: [clangd] Improve remote-index test (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90590

Files:
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py


Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===================================================================
--- clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -14,7 +14,13 @@
 from socket import socket
 import sys
 import time
-import signal
+import threading
+
+
+def kill_server_after_delay(server_process):
+  time.sleep(10)
+  if server_process.poll() is None:
+    server_process.kill()
 
 
 def main():
@@ -36,11 +42,17 @@
   ],
                                           stderr=subprocess.PIPE)
 
+  # This will kill index_server_process if it hangs without printing init
+  # message.
+  shutdown_thread = threading.Thread(
+      target=kill_server_after_delay, args=(index_server_process,))
+  shutdown_thread.daemon = True
+  shutdown_thread.start()
+
   # Wait for the server to warm-up.
-  time.sleep(4)
   found_init_message = False
-  for line in index_server_process.stderr:
-    if b'Server listening' in line:
+  while index_server_process.poll() is None:
+    if b'Server listening' in index_server_process.stderr.readline():
       found_init_message = True
       break
 
@@ -56,7 +68,7 @@
                                     stdin=in_file)
 
   clangd_process.wait()
-  os.kill(index_server_process.pid, signal.SIGINT)
+  index_server_process.kill()
 
 
 if __name__ == '__main__':


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90590.302225.patch
Type: text/x-patch
Size: 1418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201102/b86734fe/attachment.bin>


More information about the cfe-commits mailing list