Catch cabal configure failure properly

This commit is contained in:
Daniel Gröber
2014-08-18 08:06:36 +02:00
parent 6fec1de4b3
commit 271ff4e162
11 changed files with 90 additions and 30 deletions

View File

@@ -34,7 +34,7 @@ spec = do
withDirectory "test/data/subdir1/subdir2" $ \dir -> do
cradle <- findCradle
pkgDesc <- runD $ parseCabalFile $ fromJust $ cradleCabalFile cradle
res <- getCompilerOptions [] cradle pkgDesc
res <- runD $ getCompilerOptions [] cradle pkgDesc
let res' = res {
ghcOptions = ghcOptions res
, includeDirs = map (toRelativeDir dir) (includeDirs res)

View File

@@ -1,6 +1,9 @@
module UtilsSpec where
import Language.Haskell.GhcMod.Utils
import System.IO.Error
import Control.Exception
import TestUtils
import Test.Hspec
spec :: Spec
@@ -9,3 +12,11 @@ spec = do
it "extracts the part of a string surrounded by parentheses" $ do
extractParens "asdasdasd ( hello [ world ] )()() kljlkjlkjlk" `shouldBe` "( hello [ world ] )"
extractParens "[(PackageName \"template-haskell\",InstalledPackageId \"template-haskell-2.9.0.0-8e2a49468f3b663b671c437d8579cd28\"),(PackageName \"base\",InstalledPackageId \"base-4.7.0.0-e4567cc9a8ef85f78696b03f3547b6d5\"),(PackageName \"Cabal\",InstalledPackageId \"Cabal-1.18.1.3-b9a44a5b15a8bce47d40128ac326e369\")][][]" `shouldBe` "[(PackageName \"template-haskell\",InstalledPackageId \"template-haskell-2.9.0.0-8e2a49468f3b663b671c437d8579cd28\"),(PackageName \"base\",InstalledPackageId \"base-4.7.0.0-e4567cc9a8ef85f78696b03f3547b6d5\"),(PackageName \"Cabal\",InstalledPackageId \"Cabal-1.18.1.3-b9a44a5b15a8bce47d40128ac326e369\")]"
describe "liftMonadError" $ do
it "converts IOErrors to GhcModError" $ do
shouldReturnError $
runD' $ liftMonadError $ throw (userError "hello") >> return ""
shouldReturnError $
runD' $ liftMonadError $ readFile "/DOES_NOT_EXIST" >> return ""