Merge pull request #114 from mvoidex/fix-tests

Fixed tests on Windows
This commit is contained in:
Kazu Yamamoto 2013-03-31 18:19:32 -07:00
commit c0564a2456
5 changed files with 28 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

View File

@ -7,6 +7,8 @@ import Expectation
import Info
import Test.Hspec
import Types
import System.Process
import System.Exit
spec :: Spec
spec = do
@ -48,3 +50,7 @@ spec = do
cradle <- getGHCVersion >>= findCradle Nothing . fst
res <- infoExpr defaultOptions cradle "Main" "bar" "Main.hs"
res `shouldSatisfy` ("bar :: [Char]" `isPrefixOf`)
it "doesn't fail on unicode output" $ do
code <- rawSystem "dist/build/ghc-mod/ghc-mod" ["info", "test/data/Unicode.hs", "Unicode", "unicode"]
code `shouldSatisfy` (== ExitSuccess)

4
test/data/Unicode.hs Normal file
View File

@ -0,0 +1,4 @@
module Unicode where
unicode :: α -> α
unicode = id