ghc-mod/test/PathsAndFilesSpec.hs

46 lines
1.6 KiB
Haskell
Raw Normal View History

{-# LANGUAGE CPP #-}
2014-11-01 21:02:47 +00:00
module PathsAndFilesSpec where
2014-11-01 21:02:47 +00:00
import Language.Haskell.GhcMod.PathsAndFiles
2014-08-20 03:35:36 +00:00
#if __GLASGOW_HASKELL__ <= 706
2014-11-01 21:02:47 +00:00
import Language.Haskell.GhcMod.GhcPkg
2014-08-20 03:35:36 +00:00
#endif
2014-05-04 22:28:03 +00:00
import System.Directory
2015-02-07 15:41:15 +00:00
import System.FilePath
import Test.Hspec
2015-02-07 15:41:15 +00:00
import TestUtils
spec :: Spec
spec = do
describe "getSandboxDb" $ do
-- ghc < 7.8
2014-08-20 03:35:36 +00:00
#if __GLASGOW_HASKELL__ <= 706
it "does include a sandbox with ghc < 7.8" $ do
2015-02-07 15:41:15 +00:00
cwd <- getCurrentDirectory
[GlobalDb, sbPkgDb] <- getPackageDbStack "test/data/"
sbPkgDb `shouldSatisfy` isPkgDbAt (cwd </> "test/data/.cabal-sandbox")
#endif
it "can parse a config file and extract the sandbox package-db" $ do
cwd <- getCurrentDirectory
2015-02-07 15:41:15 +00:00
Just db <- getSandboxDb "test/data/"
db `shouldSatisfy` isPkgDbAt (cwd </> "test/data/.cabal-sandbox")
2014-11-01 21:02:47 +00:00
it "returns Nothing if the sandbox config file is broken" $ do
getSandboxDb "test/data/broken-sandbox" `shouldReturn` Nothing
2014-11-02 23:04:15 +00:00
2014-11-02 23:45:27 +00:00
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"
2015-02-07 15:41:15 +00:00
describe "findCabalSandboxDir" $ do
it "works" $ do
findCabalSandboxDir "test/data" `shouldReturn` Just "test/data"
it "finds sandboxes in parent directories" $ do
findCabalSandboxDir "test/data/subdir1/subdir2" `shouldReturn` Just "test/data"