From a1bc5a2cb7ef7c953ba838c5430ae585efb1a7a9 Mon Sep 17 00:00:00 2001 From: He1pa <56333845+He1pa@users.noreply.github.com> Date: Tue, 30 Apr 2024 15:16:34 +0800 Subject: [PATCH] fix: fix lsp e2e test occasionally failed in CI. (#1254) * fix: fix lsp e2e test. Add a 50ms delay to ensure write locking during compilation Signed-off-by: he1pa <18012015693@163.com> * fix: remove duplicate wait times in tests Signed-off-by: he1pa <18012015693@163.com> --------- Signed-off-by: he1pa <18012015693@163.com> --- kclvm/tools/src/LSP/src/tests.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kclvm/tools/src/LSP/src/tests.rs b/kclvm/tools/src/LSP/src/tests.rs index 6811f0977..8e750d8bb 100644 --- a/kclvm/tools/src/LSP/src/tests.rs +++ b/kclvm/tools/src/LSP/src/tests.rs @@ -84,7 +84,7 @@ use crate::util::{apply_document_changes, compile_with_params, Params}; macro_rules! wait_async_compile { () => { - thread::sleep(Duration::from_secs(2)); + thread::sleep(Duration::from_millis(50)); }; } @@ -608,12 +608,13 @@ impl Server { N::Params: Serialize, { let r = Notification::new(N::METHOD.to_string(), params); - self.send_notification(r) + self.send_notification(r); } /// Sends a server notification to the main loop fn send_notification(&self, not: Notification) { self.client.sender.send(Message::Notification(not)).unwrap(); + wait_async_compile!(); } /// A function to wait for a specific message to arrive