ghc-mod/test/CheckSpec.hs

26 lines
1.0 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)
import Expectation
2013-03-02 07:14:55 +00:00
import Test.Hspec
import Types
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"
res `shouldSatisfy` ("test/Foo.hs:3:1:Warning: Top-level binding with no type signature: foo :: [Char]\NUL\n" `isSuffixOf`)