projects
/
lsp-test.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Kill timeout thread
[lsp-test.git]
/
src
/
Language
/
LSP
/
Test
/
Parsing.hs
diff --git
a/src/Language/LSP/Test/Parsing.hs
b/src/Language/LSP/Test/Parsing.hs
index 1f5581dac73f89073d5562768245825fa9125a2a..58785d9bf5979a7227db8d7c91d674399deda8ba 100644
(file)
--- a/
src/Language/LSP/Test/Parsing.hs
+++ b/
src/Language/LSP/Test/Parsing.hs
@@
-4,7
+4,7
@@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE KindSignatures #-}
-{-# LANGUAGE
DataKinds
#-}
+{-# LANGUAGE
TypeInType
#-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
@@
-83,16
+83,21
@@
satisfyMaybeM pred = do
skipTimeout <- overridingTimeout <$> get
timeoutId <- getCurTimeoutId
skipTimeout <- overridingTimeout <$> get
timeoutId <- getCurTimeoutId
- unless skipTimeout $ do
+ mtid <-
+ if skipTimeout
+ then pure Nothing
+ else Just <$> do
chan <- asks messageChan
timeout <- asks (messageTimeout . config)
chan <- asks messageChan
timeout <- asks (messageTimeout . config)
-
void $
liftIO $ forkIO $ do
+
liftIO $ forkIO $ do
threadDelay (timeout * 1000000)
writeChan chan (TimeoutMessage timeoutId)
x <- Session await
threadDelay (timeout * 1000000)
writeChan chan (TimeoutMessage timeoutId)
x <- Session await
- unless skipTimeout (bumpTimeoutId timeoutId)
+ forM_ mtid $ \tid -> do
+ bumpTimeoutId timeoutId
+ liftIO $ killThread tid
modify $ \s -> s { lastReceivedMessage = Just x }
modify $ \s -> s { lastReceivedMessage = Just x }
@@
-110,7
+115,7
@@
named s (Session x) = Session (Data.Conduit.Parser.named s x)
-- | Matches a request or a notification coming from the server.
message :: SServerMethod m -> Session (ServerMessage m)
-- | Matches a request or a notification coming from the server.
message :: SServerMethod m -> Session (ServerMessage m)
-message m1 = named (T.pack $ show m1) $ satisfyMaybe $ \case
+message m1 = named (T.pack $
"Request for: " <>
show m1) $ satisfyMaybe $ \case
FromServerMess m2 msg -> do
HRefl <- mEqServer m1 m2
pure msg
FromServerMess m2 msg -> do
HRefl <- mEqServer m1 m2
pure msg
@@
-161,7
+166,7
@@
anyResponse = named "Any response" $ satisfy $ \case
-- | Matches a response coming from the server.
response :: SMethod (m :: Method FromClient Request) -> Session (ResponseMessage m)
-- | Matches a response coming from the server.
response :: SMethod (m :: Method FromClient Request) -> Session (ResponseMessage m)
-response m1 = named (T.pack $ show m1) $ satisfyMaybe $ \case
+response m1 = named (T.pack $
"Response for: " <>
show m1) $ satisfyMaybe $ \case
FromServerRsp m2 msg -> do
HRefl <- mEqClient m1 m2
pure msg
FromServerRsp m2 msg -> do
HRefl <- mEqClient m1 m2
pure msg