Skip to content

Commit bf6d39d

Browse files
committed
Add integration test
1 parent c435a3c commit bf6d39d

9 files changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Control.Monad (unless)
2+
import Data.List (isInfixOf)
3+
import StackTest
4+
5+
main :: IO ()
6+
main = do
7+
copy "test/Main1.hs" "test/Main.hs"
8+
copy "bench/Main1.hs" "bench/Main.hs"
9+
stack ["build"]
10+
11+
copy "test/Main2.hs" "test/Main.hs"
12+
copy "bench/Main2.hs" "bench/Main.hs"
13+
res <- unregisteringLines . snd <$> stackStderr ["build"]
14+
removeFileIgnore "test/Main.hs"
15+
removeFileIgnore "bench/Main.hs"
16+
unless (null res) $ fail "Stack recompiled when a test or benchmark file was changed, but only the library was targeted"
17+
18+
unregisteringLines :: String -> [String]
19+
unregisteringLines = filter (isInfixOf " unregistering ") . lines
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Lib
2+
3+
main :: IO ()
4+
main = putStrLn "I am Main1"
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Lib
2+
3+
main :: IO ()
4+
main = putStrLn "I am Main2"
5+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: files
2+
version: 0.1.0.0
3+
build-type: Simple
4+
cabal-version: >= 2.0
5+
6+
library
7+
hs-source-dirs: src
8+
exposed-modules: Lib
9+
build-depends: base
10+
default-language: Haskell2010
11+
12+
test-suite test
13+
hs-source-dirs: test
14+
main-is: Main.hs
15+
build-depends: base, files
16+
default-language: Haskell2010
17+
type: exitcode-stdio-1.0
18+
19+
benchmark bench
20+
hs-source-dirs: bench
21+
main-is: Main.hs
22+
build-depends: base, files
23+
default-language: Haskell2010
24+
type: exitcode-stdio-1.0
25+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module Lib where
2+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
resolver: ghc-8.2.2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Lib
2+
3+
main :: IO ()
4+
main = putStrLn "I am Main1"
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Lib
2+
3+
main :: IO ()
4+
main = putStrLn "I am Main2"
5+

0 commit comments

Comments
 (0)