Open strager opened 3 years ago
Hi, not sure if it could match your use case but in haskell-language-server we have something similar: wait for a diagnostics message with a timeout: https://github.com/haskell/haskell-language-server/blob/02d5c66af2dd2187d2e7774433829927d133d8c7/hls-test-utils/src/Test/Hls/Util.hs#L360-L393
I think the key is:
-- Send a dummy message to provoke a response from the server.
-- This guarantees that we have at least one message to
-- process, so message won't block or timeout.
In my program which uses lsp-test, I need to wait for either of the following conditions to be true:
How can I implement this with lsp-test?
I tried adding an API to lsp-test to make what I want possible. However, my implementation has problems. In short, it seems that conduit-parser is not well-suited for this task because alternatives can't "sleep"; calling
await
blocks all alternatives. Here's the code, including a failing test demonstrating some problems with my API: https://github.com/haskell/lsp/commit/06e222435c1423768c28de485044693a0f3ec68b