Skip to content

Commit

Permalink
Delete unused utilities for controlling logging. (#764)
Browse files Browse the repository at this point in the history
* Delete unused utilities for controlling logging.

Delete withFileLogging, logConfig, and noLogConfig.

Logging is turned on by hlsCommand. Should we ever want to disable it for a
certain test, we would create a new version of hlsCommand, say, hlsCommandNoLog.

* Delete unused import.

Co-authored-by: Javier Neira <[email protected]>
Co-authored-by: Junyoung Clare Jang <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 6, 2021
1 parent bf76edb commit 5737f51
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
1 change: 0 additions & 1 deletion test/functional/FunctionalBadProject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ tests = testGroup "behaviour on malformed projects" [

-- testCase "deals with cabal file with unsatisfiable dependency" $
-- runSession hlsCommandExamplePlugin codeActionSupportCaps "test/testdata/badProjects/cabal" $ do
-- -- runSessionWithConfig logConfig hlsCommandExamplePlugin codeActionSupportCaps "test/testdata" $ do
-- _doc <- openDoc "Foo.hs" "haskell"

-- diags@(d:_) <- waitForDiagnosticsSource "bios"
Expand Down
26 changes: 0 additions & 26 deletions test/utils/Test/Hls/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ module Test.Hls.Util
, inspectCommand
, inspectDiagnostic
, knownBrokenForGhcVersions
, logConfig
, logFilePath
, noLogConfig
, setupBuildToolFiles
, waitForDiagnosticsFrom
, waitForDiagnosticsFromSource
, waitForDiagnosticsFromSourceWithTimeout
, withFileLogging
, withCurrentDirectoryInTmp
)
where
Expand All @@ -52,7 +49,6 @@ import System.Directory
import System.Environment
import System.Time.Extra (Seconds, sleep)
import System.FilePath
import qualified System.Log.Logger as L
import System.IO.Temp
import System.IO.Unsafe
import Test.Hspec.Runner
Expand All @@ -63,35 +59,13 @@ import Test.Tasty.HUnit (assertFailure)
import Text.Blaze.Renderer.String (renderMarkup)
import Text.Blaze.Internal hiding (null)


noLogConfig :: Test.SessionConfig
noLogConfig = Test.defaultConfig { Test.logMessages = False }

logConfig :: Test.SessionConfig
logConfig = Test.defaultConfig { Test.logMessages = True }

codeActionSupportCaps :: C.ClientCapabilities
codeActionSupportCaps = def { C._textDocument = Just textDocumentCaps }
where
textDocumentCaps = def { C._codeAction = Just codeActionCaps }
codeActionCaps = C.CodeActionClientCapabilities (Just True) (Just literalSupport)
literalSupport = C.CodeActionLiteralSupport def

withFileLogging :: FilePath -> IO a -> IO a
withFileLogging logFile f = do
let logDir = "./test-logs"
logPath = logDir </> logFile

dirExists <- doesDirectoryExist logDir
unless dirExists $ createDirectory logDir

exists <- doesFileExist logPath
when exists $ removeFile logPath

setupLogger (Just logPath) ["hie"] L.DEBUG

f

-- ---------------------------------------------------------------------

setupBuildToolFiles :: IO ()
Expand Down

0 comments on commit 5737f51

Please sign in to comment.