@@ -59,6 +59,7 @@ import Language.LSP.Types hiding
59
59
import Language.LSP.Types.Capabilities (ClientCapabilities )
60
60
import System.Directory (getCurrentDirectory ,
61
61
setCurrentDirectory )
62
+ import System.Environment.Blank (getEnvDefault )
62
63
import System.FilePath
63
64
import System.IO.Extra
64
65
import System.IO.Unsafe (unsafePerformIO )
@@ -133,15 +134,19 @@ runSessionWithServerFormatter plugin formatter =
133
134
134
135
-- | Run an action, with stderr silenced
135
136
silenceStderr :: IO a -> IO a
136
- silenceStderr action = withTempFile $ \ temp ->
137
- bracket (openFile temp ReadWriteMode ) hClose $ \ h -> do
138
- old <- hDuplicate stderr
139
- buf <- hGetBuffering stderr
140
- h `hDuplicateTo'` stderr
141
- action `finally` do
142
- old `hDuplicateTo'` stderr
143
- hSetBuffering stderr buf
144
- hClose old
137
+ silenceStderr action = do
138
+ showStderr <- getEnvDefault " LSP_TEST_LOG_STDERR" " 0"
139
+ case showStderr of
140
+ " 0" -> withTempFile $ \ temp ->
141
+ bracket (openFile temp ReadWriteMode ) hClose $ \ h -> do
142
+ old <- hDuplicate stderr
143
+ buf <- hGetBuffering stderr
144
+ h `hDuplicateTo'` stderr
145
+ action `finally` do
146
+ old `hDuplicateTo'` stderr
147
+ hSetBuffering stderr buf
148
+ hClose old
149
+ _ -> action
145
150
146
151
-- | Restore cwd after running an action
147
152
keepCurrentDirectory :: IO a -> IO a
0 commit comments