Files
ghc-mod/test/PathsAndFilesSpec.hs

34 lines
1.3 KiB
Haskell
Raw Normal View History

2014-11-01 22:02:47 +01:00
module PathsAndFilesSpec where
2014-11-01 22:02:47 +01:00
import Language.Haskell.GhcMod.PathsAndFiles
2014-05-05 00:28:03 +02:00
import System.Directory
2015-02-07 16:41:15 +01:00
import System.FilePath
import Test.Hspec
2015-02-07 16:41:15 +01:00
import TestUtils
spec :: Spec
spec = do
describe "getSandboxDb" $ do
it "can parse a config file and extract the sandbox package-db" $ do
cwd <- getCurrentDirectory
2015-03-04 21:48:21 +01:00
Just db <- getSandboxDb "test/data/cabal-project"
db `shouldSatisfy` isPkgDbAt (cwd </> "test/data/cabal-project/.cabal-sandbox")
2014-11-01 22:02:47 +01:00
it "returns Nothing if the sandbox config file is broken" $ do
getSandboxDb "test/data/broken-sandbox" `shouldReturn` Nothing
2014-11-03 00:04:15 +01:00
2014-11-03 00:45:27 +01:00
describe "findCabalFile" $ do
it "works" $ do
2015-03-04 21:48:21 +01:00
findCabalFile "test/data/cabal-project" `shouldReturn` Just "test/data/cabal-project/cabalapi.cabal"
2014-11-03 00:45:27 +01:00
it "finds cabal files in parent directories" $ do
2015-03-04 21:48:21 +01:00
findCabalFile "test/data/cabal-project/subdir1/subdir2" `shouldReturn` Just "test/data/cabal-project/cabalapi.cabal"
2015-02-07 16:41:15 +01:00
describe "findCabalSandboxDir" $ do
it "works" $ do
2015-03-04 21:48:21 +01:00
findCabalSandboxDir "test/data/cabal-project" `shouldReturn` Just "test/data/cabal-project"
2015-02-07 16:41:15 +01:00
it "finds sandboxes in parent directories" $ do
2015-03-04 21:48:21 +01:00
findCabalSandboxDir "test/data/cabal-project/subdir1/subdir2" `shouldReturn` Just "test/data/cabal-project"