Skip to content

Commit 55c3848

Browse files
committed
More test suites and Travis integration
1 parent a863a1a commit 55c3848

File tree

8 files changed

+42
-2
lines changed

8 files changed

+42
-2
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ before_install:
2222
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc
2323
- travis_retry sudo apt-get update
2424
- travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER # see note about happy/alex
25-
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
25+
- export PATH=$HOME/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
2626

2727
install:
2828
- cabal --version
@@ -39,6 +39,9 @@ script:
3939
- cabal check
4040
- cabal sdist # tests that a source-distribution can be generated
4141

42+
- cd test/integration
43+
- stack test
44+
4245
# Check that the resulting source distribution can be built & installed.
4346
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
4447
# `cabal install --force-reinstalls dist/*-*.tar.gz`

test/integration/Dummy.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main :: IO ()
2+
main = return ()

test/integration/Spec.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ test :: FilePath -- ^ runghc
6868
-> String
6969
-> Spec
7070
test runghc env' currDir origStackRoot newHome name = it name $ withDir $ \dir -> do
71+
removeDirectoryRecursive newHome
7172
copyStackRoot origStackRoot (newHome </> takeFileName origStackRoot)
7273
let testDir = currDir </> "tests" </> name
7374
mainFile = testDir </> "Main.hs"

test/integration/lib/StackTest.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,15 @@ stackErr args = do
2929
if ec == ExitSuccess
3030
then error "stack was supposed to fail, but didn't"
3131
else return ()
32+
33+
doesNotExist :: FilePath -> IO ()
34+
doesNotExist fp = do
35+
putStrLn $ "doesNotExist " ++ fp
36+
isFile <- doesFileExist fp
37+
if isFile
38+
then error $ "File exists: " ++ fp
39+
else do
40+
isDir <- doesDirectoryExist fp
41+
if isDir
42+
then error $ "Directory exists: " ++ fp
43+
else return ()

test/integration/stack-integration-tests.cabal

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ build-type: Simple
1111
cabal-version: >=1.10
1212
homepage: https://github.com/commercialhaskell/stack
1313

14-
executable stack-integration-tests
14+
-- This is only present because cabal won't allow a test suite without a
15+
-- library or executable
16+
executable stack-integration-dummy
17+
main-is: Dummy.hs
18+
build-depends: base
19+
default-language: Haskell2010
20+
21+
test-suite stack-integration-tests
22+
type: exitcode-stdio-1.0
1523
main-is: Spec.hs
1624

1725
build-depends: base >= 4.7 && < 10
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import StackTest
2+
3+
main :: IO ()
4+
main = do
5+
stack ["install", "acme-missiles-0.3"]
6+
doesNotExist "stack.yaml"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import StackTest
2+
3+
main :: IO ()
4+
main = do
5+
stack ["unpack", "text-1.2.1.1"]
6+
stack ["init", "--resolver", "lts-2.9"]
7+
stack ["test", "--dry-run"]

test/integration/tests/sanity/Main.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ main = do
99
stackErr ["command-does-not-exist"]
1010
stackErr ["unpack", "invalid-package-name-"]
1111
stackErr ["build"]
12+
doesNotExist "stack.yaml"

0 commit comments

Comments
 (0)