Fix tests for Cabal <= 1.16

This commit is contained in:
Daniel Gröber
2014-05-09 20:37:15 +02:00
parent d1da6ab289
commit 8741323f5b
4 changed files with 27 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
{-# LANGUAGE BangPatterns, ScopedTypeVariables, TupleSections #-}
{-# LANGUAGE CPP, BangPatterns, ScopedTypeVariables, TupleSections #-}
module Language.Haskell.GhcMod.GhcPkg (
ghcPkgDbOpt
, ghcPkgDbStackOpts
@@ -12,7 +12,9 @@ module Language.Haskell.GhcMod.GhcPkg (
import Config (cProjectVersionInt)
import Control.Applicative ((<$>))
#if MIN_VERSION_Cabal(1,18,0)
import Control.Exception (SomeException(..))
#endif
import qualified Control.Exception as E
import Data.Char (isSpace)
import Data.List (isPrefixOf, intercalate)
@@ -51,8 +53,12 @@ getPackageDbStack :: FilePath -- ^ Project Directory (where the
-- exists)
-> IO [GhcPkgDb]
getPackageDbStack cdir =
#if MIN_VERSION_Cabal(1,18,0)
(getSandboxDb cdir >>= \db -> return [GlobalDb, PackageDb db])
`E.catch` \(_ :: SomeException) -> return [GlobalDb, UserDb]
#else
return [GlobalDb, UserDb]
#endif
fromInstalledPackageId' :: InstalledPackageId -> Maybe Package
fromInstalledPackageId' pid = let