Skip to content

Commit

Permalink
fix: fix lsp e2e test occasionally failed in CI. (#1254)
Browse files Browse the repository at this point in the history
* fix: fix lsp e2e test. Add a 50ms delay to ensure write locking during compilation

Signed-off-by: he1pa <[email protected]>

* fix: remove duplicate wait times in tests

Signed-off-by: he1pa <[email protected]>

---------

Signed-off-by: he1pa <[email protected]>
  • Loading branch information
He1pa authored Apr 30, 2024
1 parent eeda831 commit a1bc5a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kclvm/tools/src/LSP/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a1bc5a2

Please sign in to comment.