Skip to content

Commit b43f122

Browse files
committed
[experiment] Print debug log
1 parent a573139 commit b43f122

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

ghcide/src/Development/IDE/LSP/LanguageServer.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ exitHandler :: IO () -> LSP.Handlers (ServerM c)
185185
exitHandler exit = LSP.notificationHandler SExit $ const $ do
186186
(_, ide) <- ask
187187
-- flush out the Shake session to record a Shake profile if applicable
188+
liftIO $ logDebug (logger . shakeExtras $ ide) "Received exit message, flushing build session"
188189
liftIO $ restartShakeSession (shakeExtras ide) []
189190
liftIO exit
190191

hls-test-utils/src/Test/Hls.hs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Data.ByteString.Lazy (ByteString)
2727
import Data.Default (def)
2828
import qualified Data.Text as T
2929
import Development.IDE (IdeState, hDuplicateTo',
30-
noLogging)
30+
)
3131
import Development.IDE.Main
3232
import qualified Development.IDE.Main as Ghcide
3333
import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide
@@ -98,7 +98,7 @@ runSessionWithServer' ::
9898
FilePath ->
9999
Session a ->
100100
IO a
101-
runSessionWithServer' plugin conf sconf caps root s = silenceStderr $ do
101+
runSessionWithServer' plugin conf sconf caps root s = do
102102
(inR, inW) <- createPipe
103103
(outR, outW) <- createPipe
104104
-- restore cwd after running the session; otherwise the path to test data will be invalid
@@ -110,17 +110,19 @@ runSessionWithServer' plugin conf sconf caps root s = silenceStderr $ do
110110
{ argsHandleIn = pure inR,
111111
argsHandleOut = pure outW,
112112
argsDefaultHlsConfig = conf,
113-
argsLogger = pure noLogging,
114113
argsIdeOptions = \config sessionLoader ->
115114
let ideOptions = (argsIdeOptions def config sessionLoader) {optTesting = IdeTesting True}
116115
in ideOptions {optShakeOptions = (optShakeOptions ideOptions) {shakeThreads = 2}},
117116
argsHlsPlugins = pluginDescToIdePlugins $ plugin ++ Ghcide.descriptors
118117
}
119118

120-
x <-
121-
runSessionWithHandles inW outR sconf caps root s
122-
`finally` setCurrentDirectory cwd
119+
x <- runSessionWithHandles inW outR sconf caps root s
123120
timeout 3 (wait server) >>= \case
124121
Just () -> pure ()
125-
Nothing -> putStrLn "Server does not exit on time, canceling the async task..." >> cancel server
122+
Nothing -> do
123+
putStrLn "Server does not exit in 3s, canceling the async task..."
124+
(t, _) <- duration $ cancel server
125+
putStrLn $ "Finishing canceling (took " <> showDuration t <> "s)"
126+
setCurrentDirectory cwd
127+
sleep 0.05
126128
pure x

0 commit comments

Comments
 (0)