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

Commit 862da6b

Browse files
committed
Update tests to select libdir based on cradle
1 parent 249c1fe commit 862da6b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

test/dispatcher/Main.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import qualified Data.Text as T
1313
import Data.Default
1414
import GHC ( TypecheckedModule )
1515
import GHC.Generics
16+
import qualified Haskell.Ide.Engine.Cradle as Bios
1617
import Haskell.Ide.Engine.MonadTypes
1718
import Haskell.Ide.Engine.PluginUtils
1819
import Haskell.Ide.Engine.Scheduler
@@ -25,7 +26,7 @@ import System.FilePath
2526

2627
import Test.Hspec
2728
import Test.Hspec.Runner
28-
import System.IO
29+
import System.IO
2930

3031
-- ---------------------------------------------------------------------
3132
-- plugins
@@ -71,14 +72,16 @@ startServer :: IO (Scheduler IO, TChan LogVal, ThreadId)
7172
startServer = do
7273
scheduler <- newScheduler plugins testOptions
7374
logChan <- newTChanIO
75+
cwd <- getCurrentDirectory
76+
crdl <- Bios.findLocalCradle (cwd </> "File.hs")
7477
dispatcher <- forkIO $ do
7578
flushStackEnvironment
7679
runScheduler
7780
scheduler
7881
(\lid errCode e -> logToChan logChan ("received an error", Left (lid, errCode, e)))
7982
(\g x -> g x)
8083
def
81-
Nothing
84+
(Just crdl)
8285

8386
return (scheduler, logChan, dispatcher)
8487

test/utils/TestUtils.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Data.Maybe
3131
-- import qualified GhcMod.Types as GM
3232
import qualified Language.Haskell.LSP.Core as Core
3333
import Haskell.Ide.Engine.MonadTypes
34+
import qualified Haskell.Ide.Engine.Cradle as Bios
3435
import System.Directory
3536
import System.Environment
3637
import System.FilePath
@@ -74,7 +75,10 @@ makeRequest plugin com arg = runPluginCommand plugin com (toJSON arg)
7475
runIGM :: IdePlugins -> IdeGhcM a -> IO a
7576
runIGM testPlugins f = do
7677
stateVar <- newTVarIO $ IdeState emptyModuleCache Map.empty Map.empty Nothing
77-
runIdeGhcM Nothing testPlugins Nothing stateVar f
78+
cwd <- getCurrentDirectory
79+
crdl <- Bios.findLocalCradle (cwd </> "File.hs")
80+
mlibdir <- Bios.getProjectGhcLibDir crdl
81+
runIdeGhcM mlibdir testPlugins Nothing stateVar f
7882

7983
withFileLogging :: FilePath -> IO a -> IO a
8084
withFileLogging logFile f = do

0 commit comments

Comments
 (0)