Merge pull request #181 from eagletmt/fix-for-7.2.2

Fix for GHC 7.2.2
This commit is contained in:
Kazu Yamamoto 2014-01-13 23:10:27 -08:00
commit a2311556b5
2 changed files with 11 additions and 2 deletions

View File

@ -161,6 +161,8 @@ fOptions = [option | (option,_,_) <- fFlags]
++ [option | (option,_,_) <- fLangFlags]
#elif __GLASGOW_HASKELL__ == 702
fOptions = [option | (option,_,_,_) <- fFlags]
++ [option | (option,_,_,_) <- fWarningFlags]
++ [option | (option,_,_,_) <- fLangFlags]
#else
fOptions = [option | (option,_,_) <- fFlags]
#endif

View File

@ -1,10 +1,11 @@
module CradleSpec where
import Control.Applicative
import Data.List (isSuffixOf)
import Language.Haskell.GhcMod.Cradle
import Language.Haskell.GhcMod.Types
import System.Directory (canonicalizePath)
import System.FilePath ((</>))
import System.FilePath ((</>), pathSeparator)
import Test.Hspec
import Dir
@ -14,7 +15,7 @@ spec = do
describe "findCradle" $ do
it "returns the current directory" $ do
withDirectory_ "/" $ do
curDir <- canonicalizePath "/"
curDir <- stripLastDot <$> canonicalizePath "/"
res <- findCradle
res `shouldBe` Cradle {
cradleCurrentDir = curDir
@ -56,3 +57,9 @@ relativeCradle dir cradle = Cradle {
, cradleCabalFile = toRelativeDir dir <$> cradleCabalFile cradle
, cradlePackageDbOpts = cradlePackageDbOpts cradle
}
-- Work around GHC 7.2.2 where `canonicalizePath "/"` returns "/.".
stripLastDot :: FilePath -> FilePath
stripLastDot path
| (pathSeparator:'.':"") `isSuffixOf` path = init path
| otherwise = path