From 6be2b8f56e4e06bb23009e6a4f774a1e2bbefd1f Mon Sep 17 00:00:00 2001 From: mvoidex Date: Sun, 31 Mar 2013 18:12:34 +0400 Subject: [PATCH] Fixed tests on Windows --- Cradle.hs | 2 +- test/CheckSpec.hs | 3 ++- test/CradleSpec.hs | 27 +++++++++++++++------------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Cradle.hs b/Cradle.hs index 3cdd7b6..9932687 100644 --- a/Cradle.hs +++ b/Cradle.hs @@ -38,7 +38,7 @@ findCradle Nothing strver = do , cradlePackageConf = Nothing } Just (cdir,cfile) -> do - let sbox = cdir "cabal-dev/" + let sbox = cdir "cabal-dev" pkgConf = packageConfName sbox strver exist <- doesDirectoryExist pkgConf return Cradle { diff --git a/test/CheckSpec.hs b/test/CheckSpec.hs index a9632ce..06a0989 100644 --- a/test/CheckSpec.hs +++ b/test/CheckSpec.hs @@ -7,6 +7,7 @@ import Data.List (isSuffixOf, isInfixOf) import Expectation import Test.Hspec import Types +import System.FilePath spec :: Spec spec = do @@ -22,7 +23,7 @@ spec = do withDirectory_ "test/data/check-test-subdir" $ do cradle <- getGHCVersion >>= findCradle Nothing . fst res <- checkSyntax defaultOptions cradle "test/Bar/Baz.hs" - res `shouldSatisfy` ("test/Foo.hs:3:1:Warning: Top-level binding with no type signature: foo :: [Char]\NUL\n" `isSuffixOf`) + res `shouldSatisfy` (("test" "Foo.hs:3:1:Warning: Top-level binding with no type signature: foo :: [Char]\NUL\n") `isSuffixOf`) it "can detect mutually imported modules" $ do withDirectory_ "test/data" $ do diff --git a/test/CradleSpec.hs b/test/CradleSpec.hs index 16cd5a8..325e4ac 100644 --- a/test/CradleSpec.hs +++ b/test/CradleSpec.hs @@ -4,18 +4,20 @@ import Control.Applicative import Cradle import Data.List (isPrefixOf) import Expectation -import System.FilePath (addTrailingPathSeparator) +import System.FilePath (addTrailingPathSeparator, ()) import Test.Hspec import Types +import System.Directory (canonicalizePath) spec :: Spec spec = do describe "findCradle" $ do it "returns the current directory" $ do withDirectory_ "/" $ do + curDir <- canonicalizePath "/" res <- findCradle Nothing "7.4.1" res `shouldBe` Cradle { - cradleCurrentDir = "/" + cradleCurrentDir = curDir , cradleCabalDir = Nothing , cradleCabalFile = Nothing , cradlePackageConf = Nothing @@ -25,9 +27,9 @@ spec = do withDirectory "test/data/subdir1/subdir2" $ \dir -> do res <- relativeCradle dir <$> findCradle Nothing "7.4.1" res `shouldBe` Cradle { - cradleCurrentDir = "test/data/subdir1/subdir2" - , cradleCabalDir = Just "test/data" - , cradleCabalFile = Just "test/data/cabalapi.cabal" + cradleCurrentDir = "test" "data" "subdir1" "subdir2" + , cradleCabalDir = Just ("test" "data") + , cradleCabalFile = Just ("test" "data" "cabalapi.cabal") , cradlePackageConf = Nothing } @@ -35,20 +37,21 @@ spec = do withDirectory "test/data/subdir1/subdir2" $ \dir -> do res <- relativeCradle dir <$> findCradle Nothing "7.6.2" res `shouldBe` Cradle { - cradleCurrentDir = "test/data/subdir1/subdir2" - , cradleCabalDir = Just "test/data" - , cradleCabalFile = Just "test/data/cabalapi.cabal" - , cradlePackageConf = Just "test/data/cabal-dev/packages-7.6.2.conf" + cradleCurrentDir = "test" "data" "subdir1" "subdir2" + , cradleCabalDir = Just ("test" "data") + , cradleCabalFile = Just ("test" "data" "cabalapi.cabal") + , cradlePackageConf = Just ("test" "data" "cabal-dev" "packages-7.6.2.conf") } it "finds a sandbox if exists" $ do withDirectory "/" $ \dir -> do - res <- relativeCradle dir <$> findCradle (Just $ addTrailingPathSeparator dir ++ "test/data/cabal-dev") "7.6.2" + curDir <- canonicalizePath "/" + res <- relativeCradle dir <$> findCradle (Just $ addTrailingPathSeparator dir ++ ("test" "data" "cabal-dev")) "7.6.2" res `shouldBe` Cradle { - cradleCurrentDir = "/" + cradleCurrentDir = curDir , cradleCabalDir = Nothing , cradleCabalFile = Nothing - , cradlePackageConf = Just "test/data/cabal-dev/packages-7.6.2.conf" + , cradlePackageConf = Just ("test" "data" "cabal-dev" "packages-7.6.2.conf") } it "throws an error if the sandbox does not exist" $ do