Initilize test for stack project
This commit is contained in:
parent
320b404a8c
commit
89c3faea05
@ -73,7 +73,7 @@ stackCradle wdir = do
|
|||||||
|
|
||||||
let cabalDir = takeDirectory cabalFile
|
let cabalDir = takeDirectory cabalFile
|
||||||
|
|
||||||
stackConfigFile <- MaybeT $ findStackConfigFile cabalDir
|
_stackConfigFile <- MaybeT $ findStackConfigFile cabalDir
|
||||||
|
|
||||||
return Cradle {
|
return Cradle {
|
||||||
cradleProjectType = StackProject
|
cradleProjectType = StackProject
|
||||||
|
@ -56,6 +56,13 @@ spec = do
|
|||||||
then forM_ opts (\o -> o `shouldContain` ["-no-user-package-conf","-package-conf", cwd </> "test/data/cabal-project/.cabal-sandbox/"++ghcSandboxPkgDbDir bp])
|
then forM_ opts (\o -> o `shouldContain` ["-no-user-package-conf","-package-conf", cwd </> "test/data/cabal-project/.cabal-sandbox/"++ghcSandboxPkgDbDir bp])
|
||||||
else forM_ opts (\o -> o `shouldContain` ["-no-user-package-db","-package-db",cwd </> "test/data/cabal-project/.cabal-sandbox/"++ghcSandboxPkgDbDir bp])
|
else forM_ opts (\o -> o `shouldContain` ["-no-user-package-db","-package-db",cwd </> "test/data/cabal-project/.cabal-sandbox/"++ghcSandboxPkgDbDir bp])
|
||||||
|
|
||||||
|
it "handles stack project" $ do
|
||||||
|
let tdir = "test/data/stack-project"
|
||||||
|
opts <- map gmcGhcOpts <$> runD' tdir getComponents
|
||||||
|
let ghcOpts = head opts
|
||||||
|
pkgs = pkgOptions ghcOpts
|
||||||
|
pkgs `shouldBe` ["Cabal","base","new-template"]
|
||||||
|
|
||||||
it "extracts build dependencies" $ do
|
it "extracts build dependencies" $ do
|
||||||
let tdir = "test/data/cabal-project"
|
let tdir = "test/data/cabal-project"
|
||||||
opts <- map gmcGhcOpts <$> runD' tdir getComponents
|
opts <- map gmcGhcOpts <$> runD' tdir getComponents
|
||||||
|
@ -28,6 +28,11 @@ main = do
|
|||||||
genSandboxCfg `mapM_` sandboxes
|
genSandboxCfg `mapM_` sandboxes
|
||||||
genGhcPkgCache `mapM_` pkgDirs
|
genGhcPkgCache `mapM_` pkgDirs
|
||||||
|
|
||||||
|
let stackDir = "test/data/stack-project"
|
||||||
|
withDirectory stackDir $ \_ -> do
|
||||||
|
system "stack init --force"
|
||||||
|
system "stack build"
|
||||||
|
|
||||||
let caches = [ "setup-config"
|
let caches = [ "setup-config"
|
||||||
, "setup-config.ghc-mod.cabal-helper"
|
, "setup-config.ghc-mod.cabal-helper"
|
||||||
, "setup-config.ghc-mod.cabal-components"
|
, "setup-config.ghc-mod.cabal-components"
|
||||||
|
@ -25,6 +25,10 @@ spec = do
|
|||||||
it "finds cabal files in parent directories" $ do
|
it "finds cabal files in parent directories" $ do
|
||||||
findCabalFile "test/data/cabal-project/subdir1/subdir2" `shouldReturn` Just "test/data/cabal-project/cabalapi.cabal"
|
findCabalFile "test/data/cabal-project/subdir1/subdir2" `shouldReturn` Just "test/data/cabal-project/cabalapi.cabal"
|
||||||
|
|
||||||
|
describe "findStackConfigFile" $ do
|
||||||
|
it "works" $ do
|
||||||
|
findStackConfigFile "test/data/stack-project" `shouldReturn` Just "test/data/stack-project/stack.yaml"
|
||||||
|
|
||||||
describe "findCabalSandboxDir" $ do
|
describe "findCabalSandboxDir" $ do
|
||||||
it "works" $ do
|
it "works" $ do
|
||||||
findCabalSandboxDir "test/data/cabal-project" `shouldReturn` Just "test/data/cabal-project"
|
findCabalSandboxDir "test/data/cabal-project" `shouldReturn` Just "test/data/cabal-project"
|
||||||
|
2
test/data/stack-project/Setup.hs
Normal file
2
test/data/stack-project/Setup.hs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import Distribution.Simple
|
||||||
|
main = defaultMain
|
6
test/data/stack-project/app/Main.hs
Normal file
6
test/data/stack-project/app/Main.hs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module Main where
|
||||||
|
|
||||||
|
import Lib
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = someFunc
|
41
test/data/stack-project/new-template.cabal
Normal file
41
test/data/stack-project/new-template.cabal
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
name: new-template
|
||||||
|
version: 0.1.0.0
|
||||||
|
synopsis: Initial project template from stack
|
||||||
|
description: Please see README.md
|
||||||
|
homepage: http://github.com/name/project
|
||||||
|
-- license: BSD3
|
||||||
|
-- license-file: LICENSE
|
||||||
|
author: Your name here
|
||||||
|
maintainer: your.address@example.com
|
||||||
|
-- copyright:
|
||||||
|
category: Web
|
||||||
|
build-type: Simple
|
||||||
|
-- extra-source-files:
|
||||||
|
cabal-version: >=1.10
|
||||||
|
|
||||||
|
library
|
||||||
|
hs-source-dirs: src
|
||||||
|
exposed-modules: Lib
|
||||||
|
build-depends: base >= 4.7 && < 5
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
executable new-template-exe
|
||||||
|
hs-source-dirs: app
|
||||||
|
main-is: Main.hs
|
||||||
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
|
build-depends: base
|
||||||
|
, new-template
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
test-suite new-template-test
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
hs-source-dirs: test
|
||||||
|
main-is: Spec.hs
|
||||||
|
build-depends: base
|
||||||
|
, new-template
|
||||||
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
source-repository head
|
||||||
|
type: git
|
||||||
|
location: https://github.com/name/project
|
6
test/data/stack-project/src/Lib.hs
Normal file
6
test/data/stack-project/src/Lib.hs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module Lib
|
||||||
|
( someFunc
|
||||||
|
) where
|
||||||
|
|
||||||
|
someFunc :: IO ()
|
||||||
|
someFunc = putStrLn "someFunc"
|
2
test/data/stack-project/test/Spec.hs
Normal file
2
test/data/stack-project/test/Spec.hs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
main :: IO ()
|
||||||
|
main = putStrLn "Test suite not yet implemented"
|
Loading…
Reference in New Issue
Block a user