test for Cabal where exec depends on its lib and its fix code.

This commit is contained in:
Kazu Yamamoto 2013-02-13 15:28:29 +09:00
parent c63f04a926
commit a05e4e817d
8 changed files with 89 additions and 1 deletions

View File

@ -47,9 +47,14 @@ fromCabal ghcOptions = do
idirs = case hsSourceDirs of
[] -> [cdir,owdir]
dirs -> map (cdir </>) dirs ++ [owdir]
depPkgs <- cabalDependPackages cabal
depPkgs <- removeMe cfile <$> cabalDependPackages cabal
return (gopts,idirs,depPkgs)
removeMe :: FilePath -> [String] -> [String]
removeMe cabalfile depPkgs = filter (/= me) depPkgs
where
me = dropExtension $ takeFileName cabalfile
----------------------------------------------------------------
-- CurrentWorkingDir, CabalDir, CabalFile

View File

@ -70,6 +70,7 @@ Test-Suite spec
BrowseSpec
CabalSpec
CabalApiSpec
CheckSpec
FlagSpec
LangSpec
LintSpec

14
test/CheckSpec.hs Normal file
View File

@ -0,0 +1,14 @@
module CheckSpec where
import Test.Hspec
import Check
import Expectation
import Types
spec :: Spec
spec = do
describe "checkSyntax" $ do
it "can check even if an executable depends on its library" $ do
withDirectory "test/data/ghc-mod-check" $ do
res <- checkSyntax defaultOptions "main.hs"
res `shouldBe` "main.hs:5:1:Warning:Top-level binding with no type signature: main :: IO ()\NUL\n"

View File

@ -0,0 +1,4 @@
module Data.Foo where
foo :: Int
foo = undefined

View File

@ -0,0 +1,30 @@
Copyright (c) 2013, Kazu Yamamoto
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Kazu Yamamoto nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

View File

@ -0,0 +1,27 @@
-- Initial ghc-mod-check.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: ghc-mod-check
version: 0.1.0.0
synopsis: check test
-- description:
license: BSD3
license-file: LICENSE
author: Kazu Yamamoto
maintainer: kazu@iij.ad.jp
-- copyright:
category: Data
build-type: Simple
cabal-version: >=1.8
library
-- exposed-modules:
-- other-modules:
build-depends: base
exposed-modules: Data.Foo
executable foo
Main-Is: main.hs
GHC-Options: -Wall
Build-Depends: base >= 4 && < 5
, ghc-mod-check

View File

@ -0,0 +1,5 @@
module Main where
import Data.Foo
main = print foo