Fixed tests on Windows
This commit is contained in:
parent
653912a066
commit
6be2b8f56e
@ -38,7 +38,7 @@ findCradle Nothing strver = do
|
|||||||
, cradlePackageConf = Nothing
|
, cradlePackageConf = Nothing
|
||||||
}
|
}
|
||||||
Just (cdir,cfile) -> do
|
Just (cdir,cfile) -> do
|
||||||
let sbox = cdir </> "cabal-dev/"
|
let sbox = cdir </> "cabal-dev"
|
||||||
pkgConf = packageConfName sbox strver
|
pkgConf = packageConfName sbox strver
|
||||||
exist <- doesDirectoryExist pkgConf
|
exist <- doesDirectoryExist pkgConf
|
||||||
return Cradle {
|
return Cradle {
|
||||||
|
@ -7,6 +7,7 @@ import Data.List (isSuffixOf, isInfixOf)
|
|||||||
import Expectation
|
import Expectation
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Types
|
import Types
|
||||||
|
import System.FilePath
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = do
|
spec = do
|
||||||
@ -22,7 +23,7 @@ spec = do
|
|||||||
withDirectory_ "test/data/check-test-subdir" $ do
|
withDirectory_ "test/data/check-test-subdir" $ do
|
||||||
cradle <- getGHCVersion >>= findCradle Nothing . fst
|
cradle <- getGHCVersion >>= findCradle Nothing . fst
|
||||||
res <- checkSyntax defaultOptions cradle "test/Bar/Baz.hs"
|
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
|
it "can detect mutually imported modules" $ do
|
||||||
withDirectory_ "test/data" $ do
|
withDirectory_ "test/data" $ do
|
||||||
|
@ -4,18 +4,20 @@ import Control.Applicative
|
|||||||
import Cradle
|
import Cradle
|
||||||
import Data.List (isPrefixOf)
|
import Data.List (isPrefixOf)
|
||||||
import Expectation
|
import Expectation
|
||||||
import System.FilePath (addTrailingPathSeparator)
|
import System.FilePath (addTrailingPathSeparator, (</>))
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Types
|
import Types
|
||||||
|
import System.Directory (canonicalizePath)
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = do
|
spec = do
|
||||||
describe "findCradle" $ do
|
describe "findCradle" $ do
|
||||||
it "returns the current directory" $ do
|
it "returns the current directory" $ do
|
||||||
withDirectory_ "/" $ do
|
withDirectory_ "/" $ do
|
||||||
|
curDir <- canonicalizePath "/"
|
||||||
res <- findCradle Nothing "7.4.1"
|
res <- findCradle Nothing "7.4.1"
|
||||||
res `shouldBe` Cradle {
|
res `shouldBe` Cradle {
|
||||||
cradleCurrentDir = "/"
|
cradleCurrentDir = curDir
|
||||||
, cradleCabalDir = Nothing
|
, cradleCabalDir = Nothing
|
||||||
, cradleCabalFile = Nothing
|
, cradleCabalFile = Nothing
|
||||||
, cradlePackageConf = Nothing
|
, cradlePackageConf = Nothing
|
||||||
@ -25,9 +27,9 @@ spec = do
|
|||||||
withDirectory "test/data/subdir1/subdir2" $ \dir -> do
|
withDirectory "test/data/subdir1/subdir2" $ \dir -> do
|
||||||
res <- relativeCradle dir <$> findCradle Nothing "7.4.1"
|
res <- relativeCradle dir <$> findCradle Nothing "7.4.1"
|
||||||
res `shouldBe` Cradle {
|
res `shouldBe` Cradle {
|
||||||
cradleCurrentDir = "test/data/subdir1/subdir2"
|
cradleCurrentDir = "test" </> "data" </> "subdir1" </> "subdir2"
|
||||||
, cradleCabalDir = Just "test/data"
|
, cradleCabalDir = Just ("test" </> "data")
|
||||||
, cradleCabalFile = Just "test/data/cabalapi.cabal"
|
, cradleCabalFile = Just ("test" </> "data" </> "cabalapi.cabal")
|
||||||
, cradlePackageConf = Nothing
|
, cradlePackageConf = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,20 +37,21 @@ spec = do
|
|||||||
withDirectory "test/data/subdir1/subdir2" $ \dir -> do
|
withDirectory "test/data/subdir1/subdir2" $ \dir -> do
|
||||||
res <- relativeCradle dir <$> findCradle Nothing "7.6.2"
|
res <- relativeCradle dir <$> findCradle Nothing "7.6.2"
|
||||||
res `shouldBe` Cradle {
|
res `shouldBe` Cradle {
|
||||||
cradleCurrentDir = "test/data/subdir1/subdir2"
|
cradleCurrentDir = "test" </> "data" </> "subdir1" </> "subdir2"
|
||||||
, cradleCabalDir = Just "test/data"
|
, cradleCabalDir = Just ("test" </> "data")
|
||||||
, cradleCabalFile = Just "test/data/cabalapi.cabal"
|
, cradleCabalFile = Just ("test" </> "data" </> "cabalapi.cabal")
|
||||||
, cradlePackageConf = Just "test/data/cabal-dev/packages-7.6.2.conf"
|
, cradlePackageConf = Just ("test" </> "data" </> "cabal-dev" </> "packages-7.6.2.conf")
|
||||||
}
|
}
|
||||||
|
|
||||||
it "finds a sandbox if exists" $ do
|
it "finds a sandbox if exists" $ do
|
||||||
withDirectory "/" $ \dir -> 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 {
|
res `shouldBe` Cradle {
|
||||||
cradleCurrentDir = "/"
|
cradleCurrentDir = curDir
|
||||||
, cradleCabalDir = Nothing
|
, cradleCabalDir = Nothing
|
||||||
, cradleCabalFile = 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
|
it "throws an error if the sandbox does not exist" $ do
|
||||||
|
Loading…
Reference in New Issue
Block a user