Fix findCabalFile

This commit is contained in:
Daniel Gröber
2014-11-03 00:45:27 +01:00
parent 506cf18885
commit 9a8a3651d0
4 changed files with 16 additions and 11 deletions

View File

@@ -3,7 +3,6 @@
module CabalApiSpec where
import Control.Applicative
import Data.Maybe
import Language.Haskell.GhcMod.CabalApi
import Language.Haskell.GhcMod.Cradle
import Language.Haskell.GhcMod.Types
@@ -35,7 +34,7 @@ spec = do
cwd <- getCurrentDirectory
withDirectory "test/data/subdir1/subdir2" $ \dir -> do
crdl <- findCradle
let cabalFile = cradleCabalFile crdl
let Just cabalFile = cradleCabalFile crdl
pkgDesc <- runD $ parseCabalFile crdl cabalFile
res <- runD $ getCompilerOptions [] crdl pkgDesc
let res' = res {

View File

@@ -33,3 +33,10 @@ spec = do
describe "getCabalFiles" $ do
it "doesn't think $HOME/.cabal is a cabal file" $ do
(getCabalFiles =<< getEnv "HOME") `shouldReturn` []
describe "findCabalFile" $ do
it "works" $ do
findCabalFile "test/data" `shouldReturn` Just "test/data/cabalapi.cabal"
it "finds cabal files in parent directories" $ do
findCabalFile "test/data/subdir1/subdir2" `shouldReturn` Just "test/data/cabalapi.cabal"