Skip to content

Commit

Permalink
Put tests back
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpj committed May 19, 2024
1 parent b995ad6 commit 0e0a492
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
30 changes: 28 additions & 2 deletions test/functional/Progress.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ module Progress (tests) where
import Control.Exception (throw)
import Control.Lens hiding ((.=))
import Data.Aeson (decode, encode)
import Data.Functor (void)
import Data.List (delete)
import Data.Maybe (fromJust)
import Data.Text (Text)
import Data.Text (Text, pack)
import Ide.Types
import Language.LSP.Protocol.Capabilities
import qualified Language.LSP.Protocol.Lens as L
import Test.Hls
Expand All @@ -23,7 +25,12 @@ tests :: TestTree
tests =
testGroup
"window/workDoneProgress"
[ requiresEvalPlugin $ testCase "eval plugin sends progress reports" $
[ testCase "sends indefinite progress notifications" $
runSession hlsLspCommand progressCaps "test/testdata/diagnostics" $ do
let path = "Foo.hs"
_ <- openDoc path "haskell"
expectProgressMessages [pack ("Setting up diagnostics (for " ++ path ++ ")"), "Processing", "Indexing"] [] []
, requiresEvalPlugin $ testCase "eval plugin sends progress reports" $
runSession hlsLspCommand progressCaps "plugins/hls-eval-plugin/test/testdata" $ do
doc <- openDoc "TIO.hs" "haskell"
lspId <- sendRequest SMethod_TextDocumentCodeLens (CodeLensParams Nothing Nothing doc)
Expand All @@ -48,8 +55,27 @@ tests =

expectProgressMessages ["Evaluating"] createdProgressTokens activeProgressTokens
_ -> error $ "Unexpected response result: " ++ show response
, requiresOrmoluPlugin $ testCase "ormolu plugin sends progress notifications" $ do
runSessionWithConfig (def { ignoreConfigurationRequests = False }) hlsLspCommand progressCaps "test/testdata/format" $ do
void configurationRequest
setHlsConfig (formatLspConfig "ormolu")
doc <- openDoc "Format.hs" "haskell"
expectProgressMessages ["Setting up format (for Format.hs)", "Processing", "Indexing"] [] []
_ <- sendRequest SMethod_TextDocumentFormatting $ DocumentFormattingParams Nothing doc (FormattingOptions 2 True Nothing Nothing Nothing)
expectProgressMessages ["Formatting Format.hs"] [] []
, requiresFourmoluPlugin $ testCase "fourmolu plugin sends progress notifications" $ do
runSessionWithConfig (def { ignoreConfigurationRequests = False }) hlsLspCommand progressCaps "test/testdata/format" $ do
void configurationRequest
setHlsConfig (formatLspConfig "fourmolu")
doc <- openDoc "Format.hs" "haskell"
expectProgressMessages ["Setting up format (for Format.hs)", "Processing", "Indexing"] [] []
_ <- sendRequest SMethod_TextDocumentFormatting $ DocumentFormattingParams Nothing doc (FormattingOptions 2 True Nothing Nothing Nothing)
expectProgressMessages ["Formatting Format.hs"] [] []
]

formatLspConfig :: Text -> Config
formatLspConfig provider = def { formattingProvider = provider }

progressCaps :: ClientCapabilities
progressCaps = fullCaps{_window = Just (WindowClientCapabilities (Just True) Nothing Nothing)}

Expand Down
4 changes: 2 additions & 2 deletions test/utils/Test/Hls/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ hlsExeCommand = unsafePerformIO $ do
pure testExe

hlsLspCommand :: String
hlsLspCommand = hlsExeCommand ++ " --lsp -d -j4"
hlsLspCommand = hlsExeCommand ++ " --lsp --test -d -j4"

hlsWrapperLspCommand :: String
hlsWrapperLspCommand = hlsWrapperExeCommand ++ " --lsp -d -j4"
hlsWrapperLspCommand = hlsWrapperExeCommand ++ " --lsp --test -d -j4"

hlsWrapperExeCommand :: String
{-# NOINLINE hlsWrapperExeCommand #-}
Expand Down

0 comments on commit 0e0a492

Please sign in to comment.