Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Multi main #645

Merged
merged 2 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion test/Functional.hs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ spec = do
)
Nothing

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

describe "multi-server setup" $
it "doesn't have clashing commands on two servers" $ do
let getCommands = runSession hieCommand "test/testdata" $ do
Expand All @@ -156,6 +158,8 @@ spec = do
List uuids2 <- getCommands
liftIO $ forM_ (zip uuids1 uuids2) (uncurry shouldNotBe)

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

describe "code actions" $
it "provide hlint suggestions" $ runSession hieCommand "test/testdata" $ do
doc <- openDoc "ApplyRefact2.hs" "haskell"
Expand All @@ -180,4 +184,24 @@ spec = do
liftIO $ do
length cmds `shouldBe` 1
evaluateCmd ^. title `shouldBe` "Apply hint:Evaluate"


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

describe "multiple main modules" $
it "Can load one file at a time, when more than one Main module exists"
-- $ runSession hieCommand "test/testdata" $ do
$ runSession hieCommandVomit "test/testdata" $ do
_doc <- openDoc "ApplyRefact2.hs" "haskell"
_diagsRspHlint <- skipManyTill anyNotification notification :: Session PublishDiagnosticsNotification
diagsRspGhc <- skipManyTill anyNotification notification :: Session PublishDiagnosticsNotification
let (List diags) = diagsRspGhc ^. params . diagnostics

liftIO $ length diags `shouldBe` 2

_doc2 <- openDoc "HaReRename.hs" "haskell"
_diagsRspHlint2 <- skipManyTill anyNotification notification :: Session PublishDiagnosticsNotification
-- errMsg <- skipManyTill anyNotification notification :: Session ShowMessageNotification
diagsRsp2 <- skipManyTill anyNotification notification :: Session PublishDiagnosticsNotification
let (List diags2) = diagsRsp2 ^. params . diagnostics

liftIO $ show diags2 `shouldBe` "[]"
4 changes: 4 additions & 0 deletions test/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module TestUtils
, makeRequest
, runIGM
, hieCommand
, hieCommandVomit
) where

import Control.Exception
Expand Down Expand Up @@ -120,6 +121,9 @@ stackYaml =
hieCommand :: String
hieCommand = "stack exec --stack-yaml=" ++ stackYaml ++ " hie -- --lsp -d -l test-logs/functional-hie.log"

hieCommandVomit :: String
hieCommandVomit = hieCommand ++ " --vomit"

-- |Choose a resolver based on the current compiler, otherwise HaRe/ghc-mod will
-- not be able to load the files
readResolver :: IO String
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/ApplyRefact2.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
main = undefined
foo x = id x
foo x = id x