Fixed tests on Windows

This commit is contained in:
mvoidex 2013-03-31 18:12:34 +04:00
parent 653912a066
commit 6be2b8f56e
3 changed files with 18 additions and 14 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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