Skip to content

Commit

Permalink
honor LSP_TEST_LOG_STDERR
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra committed Oct 24, 2021
1 parent 254b4b6 commit 395389a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hls-test-utils/src/Test/Hls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Data.Aeson (Value (Null), toJSON)
import qualified Data.Aeson as A
import Data.ByteString.Lazy (ByteString)
import Data.Default (def)
import Data.Maybe (fromMaybe)
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Encoding as TL
Expand All @@ -64,6 +65,7 @@ import Language.LSP.Types hiding
import Language.LSP.Types.Capabilities (ClientCapabilities)
import System.Directory (getCurrentDirectory,
setCurrentDirectory)
import System.Environment (lookupEnv)
import System.FilePath
import System.IO.Unsafe (unsafePerformIO)
import System.Process.Extra (createPipe)
Expand Down Expand Up @@ -160,14 +162,20 @@ runSessionWithServer' ::
runSessionWithServer' plugin conf sconf caps root s = withLock lock $ keepCurrentDirectory $ do
(inR, inW) <- createPipe
(outR, outW) <- createPipe
let logger = do
logStdErr <- fromMaybe "0" <$> lookupEnv "LSP_TEST_LOG_STDERR"
if logStdErr == "0"
then return noLogging
else argsLogger testing

server <-
async $
Ghcide.defaultMain
testing
{ argsHandleIn = pure inR,
argsHandleOut = pure outW,
argsDefaultHlsConfig = conf,
argsLogger = pure noLogging,
argsLogger = logger,
argsIdeOptions = \config sessionLoader ->
let ideOptions = (argsIdeOptions def config sessionLoader) {optTesting = IdeTesting True}
in ideOptions {optShakeOptions = (optShakeOptions ideOptions) {shakeThreads = 2}},
Expand Down

0 comments on commit 395389a

Please sign in to comment.