Merge branch 'master' of https://github.com/Bubba/haskell-lsp-test
authorLuke Lau <luke_lau@icloud.com>
Mon, 11 Jun 2018 14:31:29 +0000 (10:31 -0400)
committerLuke Lau <luke_lau@icloud.com>
Mon, 11 Jun 2018 14:31:29 +0000 (10:31 -0400)
1  2 
example/Main.hs
src/Language/Haskell/LSP/Test.hs
src/Language/Haskell/LSP/Test/Replay.hs
test/Test.hs

diff --cc example/Main.hs
Simple merge
index 087143fa8960537db6d71dab2c3bc70e82e83221,fb928a4b9ccd0bfbec75cd4bae66af408e885242..79b7b1e7147934150d4cf632b9c142940e2191e0
@@@ -95,11 -95,11 +96,11 @@@ runSession serverExe rootDir session = 
                                            def
                                            (Just TraceOff)
  
 -  runSessionWithHandler listenServer rootDir $ do
 +  runSessionWithHandler listenServer serverExe rootDir $ do
  
      -- Wrap the session around initialize and shutdown calls
-     sendRequest (Proxy :: Proxy InitializeRequest) Initialize initializeParams
-     RspInitialize initRsp <- response
+     sendRequest Initialize initializeParams
+     initRsp <- response :: Session InitializeResponse
      liftIO $ maybe (return ()) (putStrLn . ("Error while initializing: " ++) . show ) (initRsp ^. LSP.error)
  
      sendNotification Initialized InitializedParams
index 4802c9ad152afb7b57d8a2a7d906d81b99a459a8,2d5e4e612284ab6c3329a5aa7c36c548f45a1ef2..dfa364b44c3600b4682eca2f94699f2fea16fad3
@@@ -51,10 -50,14 +51,15 @@@ replaySession serverExe sessionDir = d
    rspSema <- newEmptyMVar
    passVar <- newEmptyMVar :: IO (MVar Bool)
  
-   forkIO $ runSessionWithHandler (listenServer serverMsgs requestMap reqSema rspSema passVar) serverExe sessionDir $
-     sendMessages clientMsgs reqSema rspSema
+   threadId <- forkIO $
+     runSessionWithHandler (listenServer serverMsgs requestMap reqSema rspSema passVar)
++                          serverExe
+                           sessionDir
+                           (sendMessages clientMsgs reqSema rspSema)
  
-   takeMVar passVar
+   result <- takeMVar passVar
+   killThread threadId
+   return result
  
    where
      isClientMsg (FromClient _ _) = True
diff --cc test/Test.hs
index c7e67131d914875b1fb41f98cb8928b8dba1f7e5,ca135c7a379c3790f80e640262610b8887bde55b..426dd6bd704f3df283e2f19e7ac08609697211d9
@@@ -11,10 -10,9 +10,9 @@@ import           Language.Haskell.LSP.T
  import           ParsingTests
  
  main = hspec $ do
-   describe "manual session validation" $ do
+   describe "manual session" $ do
      it "passes a test" $
 -      runSession "test/recordings/renamePass" $ do
 +      runSession "hie" "test/recordings/renamePass" $ do
          doc <- openDoc "Desktop/simple.hs" "haskell"
  
          skipMany loggingNotification
      
      it "fails a test" $
        -- TODO: Catch the exception in haskell-lsp-test and provide nicer output
 -      let session = runSession "test/recordings/renamePass" $ do
 +      let session = runSession "hie" "test/recordings/renamePass" $ do
                        openDoc "Desktop/simple.hs" "haskell"
                        skipMany loggingNotification
-                     request
+                       anyRequest
          in session `shouldThrow` anyException
    
    describe "replay session" $ do