ghc-mod/test/GhcPkgSpec.hs

33 lines
1.1 KiB
Haskell
Raw Normal View History

module GhcPkgSpec where
import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.GhcPkg
2014-05-04 22:28:03 +00:00
import Language.Haskell.GhcMod.Monad
import CoreMonad (liftIO)
import Control.Applicative
import System.Directory
import System.FilePath ((</>))
import Test.Hspec
import Dir
spec :: Spec
spec = do
describe "getSandboxDb" $ do
it "parses a config file and extracts sandbox package db" $ do
cwd <- getCurrentDirectory
pkgDb <- getSandboxDb "test/data/"
pkgDb `shouldBe` (cwd </> "test/data/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d")
it "throws an error if a config file is broken" $ do
getSandboxDb "test/data/broken-sandbox" `shouldThrow` anyException
describe "getPackageDbPackages" $ do
2014-05-04 22:28:03 +00:00
it "find a config file and extracts packages" $
runGhcMod defaultOptions $ do
sdb <- liftIO $ getSandboxDb "test/data/check-packageid"
2014-04-17 21:49:23 +00:00
pkgs <- ghcPkgListEx [PackageDb sdb]
2014-05-04 22:28:03 +00:00
liftIO $ pkgs `shouldBe` [("template-haskell","2.8.0.0","32d4f24abdbb6bf41272b183b2e23e9c")]