Skip to content

Commit

Permalink
Remove weird test
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpj committed Jun 20, 2023
1 parent 6824b78 commit 9553008
Showing 1 changed file with 13 additions and 36 deletions.
49 changes: 13 additions & 36 deletions test/functional/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,35 @@
module Config (tests) where

import Control.DeepSeq
import Control.Lens hiding (List, (.=))
import Control.Lens hiding (List, (.=))
import Control.Monad
import Data.Aeson
import Data.Hashable
import qualified Data.HashMap.Strict as HM
import qualified Data.Map as Map
import qualified Data.Text as T
import Data.Typeable (Typeable)
import Development.IDE (RuleResult, action, define,
getFilesOfInterestUntracked,
getPluginConfigAction, ideErrorText,
uses_)
import Development.IDE.Test (expectDiagnostics)
import qualified Data.HashMap.Strict as HM
import qualified Data.Map as Map
import qualified Data.Text as T
import Data.Typeable (Typeable)
import Development.IDE (RuleResult, action, define,
getFilesOfInterestUntracked,
getPluginConfigAction, ideErrorText,
uses_)
import Development.IDE.Test (expectDiagnostics)
import GHC.Generics
import Ide.Plugin.Config
import Ide.Types
import Language.LSP.Test as Test
import qualified Language.LSP.Types.Lens as L
import System.FilePath ((</>))
import Language.LSP.Test as Test
import System.FilePath ((</>))
import Test.Hls
import Test.Hls.Command

{-# ANN module ("HLint: ignore Reduce duplication"::String) #-}

tests :: TestTree
tests = testGroup "plugin config" [
-- Note: there are more comprehensive tests over config in hls-hlint-plugin
-- TODO: Add generic tests over some example plugin
configParsingTests, genericConfigTests
genericConfigTests
]

configParsingTests :: TestTree
configParsingTests = testGroup "config parsing"
[ testCase "empty object as user configuration should not send error logMessage" $ runConfigSession "" $ do
let config = object []
sendConfigurationChanged (toJSON config)

-- Send custom request so server returns a response to prevent blocking
void $ sendNotification (SCustomMethod "non-existent-method") Null

logNot <- skipManyTill Test.anyMessage (message SWindowLogMessage)

liftIO $ (logNot ^. L.params . L.xtype) > MtError
|| "non-existent-method" `T.isInfixOf` (logNot ^. L.params . L.message)
@? "Server sends logMessage with MessageType = Error"
]

where
runConfigSession :: FilePath -> Session a -> IO a
runConfigSession subdir =
failIfSessionTimeout . runSession hlsCommand fullCaps ("test/testdata" </> subdir)

genericConfigTests :: TestTree
genericConfigTests = testGroup "generic plugin config"
[
Expand Down

0 comments on commit 9553008

Please sign in to comment.