2014-05-18 23:29:49 +00:00
|
|
|
{-# LANGUAGE CPP #-}
|
2014-04-15 03:13:10 +00:00
|
|
|
module GhcPkgSpec where
|
|
|
|
|
|
|
|
import Language.Haskell.GhcMod.GhcPkg
|
2014-05-18 23:29:49 +00:00
|
|
|
import Language.Haskell.GhcMod.Types
|
2014-05-04 22:28:03 +00:00
|
|
|
|
2014-04-15 03:13:10 +00:00
|
|
|
import System.Directory
|
|
|
|
import System.FilePath ((</>))
|
|
|
|
import Test.Hspec
|
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = do
|
2014-05-18 23:20:58 +00:00
|
|
|
describe "getSandboxDb" $ do
|
2014-05-18 23:29:49 +00:00
|
|
|
-- ghc < 7.8
|
|
|
|
#if !MIN_VERSION_ghc(7,8,0)
|
|
|
|
it "does include a sandbox with ghc < 7.8" $ do
|
|
|
|
cwd <- getCurrentDirectory
|
|
|
|
getPackageDbStack "test/data/" `shouldReturn` [GlobalDb, PackageDb $ cwd </> "test/data/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d"]
|
|
|
|
#endif
|
|
|
|
|
2014-04-15 03:13:10 +00:00
|
|
|
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
|