[PATCH] D90590: [clangd] Improve remote-index test
Kirill Bobyrev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 00:32:58 PST 2020
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Repository:
rG LLVM Github Monorepo
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.302220.patch
Type: text/x-patch
Size: 1418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201102/974fe947/attachment.bin>
More information about the cfe-commits
mailing list