-
Notifications
You must be signed in to change notification settings - Fork 846
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
013d1c4
commit 0ec3063
Showing
6 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
test/integration/tests/4105-test-coverage-of-internal-lib/Main.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Control.Monad (unless) | ||
import Data.List (isInfixOf, isPrefixOf) | ||
import StackTest | ||
|
||
main :: IO () | ||
main = do | ||
stack ["clean"] | ||
stack ["build"] | ||
res <- getCoverageLines . snd <$> stackStderr ["test", "--coverage"] | ||
case res of | ||
_:exprs:_ -> unless ("2/2" `isInfixOf` exprs) testFail | ||
_ -> testFail | ||
where | ||
testFail = fail "Stack didn't generate coverage from both libraries" | ||
|
||
getCoverageLines :: String -> [String] | ||
getCoverageLines = dropWhile (not . isCoverageHeader) . lines | ||
where | ||
isCoverageHeader = isPrefixOf "Generating coverage report for " |
23 changes: 23 additions & 0 deletions
23
test/integration/tests/4105-test-coverage-of-internal-lib/files/files.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: files | ||
version: 0.1.0.0 | ||
build-type: Simple | ||
cabal-version: >= 2.0 | ||
|
||
library | ||
exposed-modules: Src | ||
hs-source-dirs: src | ||
build-depends: base | ||
default-language: Haskell2010 | ||
|
||
library sublib | ||
exposed-modules: B | ||
hs-source-dirs: src-sublib | ||
build-depends: base | ||
default-language: Haskell2010 | ||
|
||
test-suite test | ||
type: exitcode-stdio-1.0 | ||
main-is: Main.hs | ||
hs-source-dirs: test | ||
build-depends: base, files, sublib | ||
default-language: Haskell2010 |
5 changes: 5 additions & 0 deletions
5
test/integration/tests/4105-test-coverage-of-internal-lib/files/src-sublib/B.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module B where | ||
|
||
-- | A function of the internal library | ||
funInternal :: Int -> Int | ||
funInternal = pred |
5 changes: 5 additions & 0 deletions
5
test/integration/tests/4105-test-coverage-of-internal-lib/files/src/Src.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Src where | ||
|
||
-- | A function of the main library | ||
funMainLib :: Int -> Int | ||
funMainLib = succ |
1 change: 1 addition & 0 deletions
1
test/integration/tests/4105-test-coverage-of-internal-lib/files/stack.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
resolver: lts-11.11 |
6 changes: 6 additions & 0 deletions
6
test/integration/tests/4105-test-coverage-of-internal-lib/files/test/Main.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Control.Monad (when) | ||
|
||
import Src | ||
import B | ||
|
||
main = when (funMainLib 41 /= funInternal 43) $ error "test failed" |