Refactor the way packages databases are handled
- cradle now stores a list of active package databases instead of only the user store (if present). - rename `cradlePackageDb` -> `cradlePkgDbStack` as that`s what the ghc documentaion calls this kind of thing - `getPackageDbPackages` now returns names of all visible packages in the given directory. Also the implementation now uses `ghc-pkg` instead of manually looking at the package database
This commit is contained in:
27
test/GhcPkgSpec.hs
Normal file
27
test/GhcPkgSpec.hs
Normal file
@@ -0,0 +1,27 @@
|
||||
module GhcPkgSpec where
|
||||
|
||||
import Language.Haskell.GhcMod.Types
|
||||
import Language.Haskell.GhcMod.GhcPkg
|
||||
|
||||
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
|
||||
it "find a config file and extracts packages" $ do
|
||||
pkgs <- getPackageDbPackages "test/data/check-packageid"
|
||||
pkgs `shouldSatisfy` (\x -> length x >= 1)
|
||||
Reference in New Issue
Block a user