Skip to content

Commit fbea1e4

Browse files
committed
Integration tests in the main .cabal file
Brought up by @manny-fp. Now running the full test suite is: stack test --flag stack:integration-tests
1 parent 3234153 commit fbea1e4

File tree

6 files changed

+38
-78
lines changed

6 files changed

+38
-78
lines changed

stack.cabal

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ extra-source-files: README.md ChangeLog.md
3030
new-template/LICENSE
3131
new-template/Setup.hs
3232

33+
flag integration-tests
34+
manual: True
35+
default: False
36+
description: Run the integration test suite
37+
3338
library
3439
hs-source-dirs: src/
3540
ghc-options: -Wall
@@ -212,6 +217,34 @@ test-suite stack-test
212217
, Cabal
213218
default-language: Haskell2010
214219

220+
test-suite stack-integration-test
221+
type: exitcode-stdio-1.0
222+
hs-source-dirs: test/integration
223+
main-is: Spec.hs
224+
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
225+
226+
if flag(integration-tests)
227+
buildable: True
228+
else
229+
buildable: False
230+
231+
build-depends: base >= 4.7 && < 10
232+
, temporary
233+
, hspec
234+
, process
235+
, filepath
236+
, directory
237+
, text
238+
, unix-compat
239+
, containers
240+
, conduit
241+
, conduit-extra
242+
, resourcet
243+
, async
244+
, transformers
245+
, bytestring
246+
default-language: Haskell2010
247+
215248
source-repository head
216249
type: git
217250
location: https://github.com/commercialhaskell/stack

test/integration/Dummy.hs

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/integration/LICENSE

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/integration/Spec.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import Test.Hspec
3131

3232
main :: IO ()
3333
main = do
34-
currDir <- getCurrentDirectory
34+
currDir <- canonicalizePath "test/integration"
3535

3636
let findExe name = do
3737
mexe <- findExecutable name
@@ -41,7 +41,8 @@ main = do
4141
runghc <- findExe "runghc"
4242
stack <- findExe "stack"
4343

44-
tests <- getDirectoryContents "tests" >>= filterM hasTest
44+
let testDir = currDir </> "tests"
45+
tests <- getDirectoryContents testDir >>= filterM (hasTest testDir)
4546

4647
envOrig <- getEnvironment
4748

@@ -58,8 +59,8 @@ main = do
5859

5960
hspec $ mapM_ (test runghc env' currDir origStackRoot newHome) tests
6061

61-
hasTest :: FilePath -> IO Bool
62-
hasTest dir = doesFileExist $ "tests" </> dir </> "Main.hs"
62+
hasTest :: FilePath -> FilePath -> IO Bool
63+
hasTest root dir = doesFileExist $ root </> dir </> "Main.hs"
6364

6465
test :: FilePath -- ^ runghc
6566
-> [(String, String)] -- ^ env

test/integration/stack-integration-tests.cabal

Lines changed: 0 additions & 45 deletions
This file was deleted.

test/integration/stack.yaml

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)