01e3b8e3d6
also: - cleanup LightGhc - make the new DynFlags to compare against in a clean HscEnv
48 lines
1.6 KiB
Haskell
48 lines
1.6 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
module TargetSpec where
|
|
|
|
import Language.Haskell.GhcMod.Target
|
|
import Language.Haskell.GhcMod.LightGhc
|
|
import Language.Haskell.GhcMod.Gap
|
|
import Test.Hspec
|
|
|
|
import TestUtils
|
|
|
|
import GHC
|
|
import Data.List
|
|
import Data.Maybe
|
|
import System.Directory
|
|
import System.FilePath
|
|
|
|
spec :: Spec
|
|
spec = do
|
|
describe "runLightGhc" $ do
|
|
it "works at all" $ do
|
|
withLightHscEnv [] $ \env ->
|
|
runLightGhc env (return ()) `shouldReturn` ()
|
|
|
|
it "has modules in scope" $ do
|
|
(withLightHscEnv [] $ \env ->
|
|
runLightGhc env $ do
|
|
dflags <- getSessionDynFlags
|
|
let i = intersect (listVisibleModuleNames dflags)
|
|
["Control.Applicative", "Control.Arrow"
|
|
,"Control.Exception", "GHC.Exts", "GHC.Float"]
|
|
liftIO $ i `shouldSatisfy` not . null) :: IO ()
|
|
|
|
it "can get module info" $ do
|
|
(withLightHscEnv [] $ \env ->
|
|
runLightGhc env $ do
|
|
mdl <- findModule "Data.List" Nothing
|
|
mmi <- getModuleInfo mdl
|
|
liftIO $ isJust mmi `shouldBe` True) :: IO ()
|
|
|
|
|
|
describe "resolveModule" $ do
|
|
it "Works when a module given as path uses CPP" $ do
|
|
dir <- getCurrentDirectory
|
|
let srcDirs = [dir </> "test/data/target/src"]
|
|
x <- withLightHscEnv [] $ \env -> runD $ do
|
|
resolveModule env srcDirs (Left $ dir </> "test/data/target/Cpp.hs")
|
|
liftIO $ x `shouldBe` Just (ModulePath "Cpp" $ dir </> "test/data/target/Cpp.hs")
|