ghc-mod/test/CheckSpec.hs

34 lines
1.4 KiB
Haskell
Raw Normal View History

module CheckSpec where
2013-03-04 09:11:09 +00:00
import CabalApi
import Check
2013-03-02 07:14:55 +00:00
import Cradle
import Data.List (isSuffixOf, isInfixOf)
import Expectation
2013-03-02 07:14:55 +00:00
import Test.Hspec
import Types
2013-03-31 14:12:34 +00:00
import System.FilePath
spec :: Spec
spec = do
describe "checkSyntax" $ do
it "can check even if an executable depends on its library" $ do
2013-03-05 01:22:33 +00:00
withDirectory_ "test/data/ghc-mod-check" $ do
2013-03-04 09:11:09 +00:00
(strVer,_) <- getGHCVersion
cradle <- findCradle Nothing strVer
2013-03-02 07:14:55 +00:00
res <- checkSyntax defaultOptions cradle "main.hs"
res `shouldBe` "main.hs:5:1:Warning: Top-level binding with no type signature: main :: IO ()\NUL\n"
it "can check even if a test module imports another test module located at different directory" $ do
withDirectory_ "test/data/check-test-subdir" $ do
cradle <- getGHCVersion >>= findCradle Nothing . fst
res <- checkSyntax defaultOptions cradle "test/Bar/Baz.hs"
2013-03-31 14:12:34 +00:00
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
(strVer,_) <- getGHCVersion
cradle <- findCradle Nothing strVer
res <- checkSyntax defaultOptions cradle "Mutual1.hs"
res `shouldSatisfy` ("Module imports form a cycle" `isInfixOf`)