-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test-cases for extracting build-info, even if a component failed …
…to build
- Loading branch information
Showing
10 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/CompileFail.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,29 @@ | ||
cabal-version: 3.0 | ||
name: CompileFail | ||
version: 0.1.0.0 | ||
build-type: Simple | ||
|
||
library | ||
exposed-modules: MyLib | ||
build-depends: base | ||
hs-source-dirs: src | ||
default-language: Haskell2010 | ||
|
||
library failing | ||
exposed-modules: MyLib2 | ||
build-depends: base | ||
hs-source-dirs: src | ||
default-language: Haskell2010 | ||
|
||
test-suite CompileFail-test | ||
default-language: Haskell2010 | ||
type: exitcode-stdio-1.0 | ||
hs-source-dirs: test | ||
main-is: Main.hs | ||
build-depends: base, CompileFail | ||
|
||
executable CompileFail-exe | ||
default-language: Haskell2010 | ||
hs-source-dirs: app | ||
main-is: Main.hs | ||
build-depends: base, failing |
6 changes: 6 additions & 0 deletions
6
cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/app/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 @@ | ||
module Main where | ||
|
||
import MyLib2 (someFunc2) | ||
|
||
main :: IO () | ||
main = someFunc2 |
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/cabal.project
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 @@ | ||
packages: ./ |
22 changes: 22 additions & 0 deletions
22
cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/compile-fail.out
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,22 @@ | ||
# cabal build | ||
Resolving dependencies... | ||
Build profile: -w ghc-<GHCVER> -O1 | ||
In order, the following will be built: | ||
- CompileFail-0.1.0.0 (lib) (first run) | ||
- CompileFail-0.1.0.0 (test:CompileFail-test) (first run) | ||
Configuring library for CompileFail-0.1.0.0.. | ||
Preprocessing library for CompileFail-0.1.0.0.. | ||
Building library for CompileFail-0.1.0.0.. | ||
Configuring test suite 'CompileFail-test' for CompileFail-0.1.0.0.. | ||
Preprocessing test suite 'CompileFail-test' for CompileFail-0.1.0.0.. | ||
Building test suite 'CompileFail-test' for CompileFail-0.1.0.0.. | ||
# cabal build | ||
Build profile: -w ghc-<GHCVER> -O1 | ||
In order, the following will be built: | ||
- CompileFail-0.1.0.0 (lib:failing) (first run) | ||
- CompileFail-0.1.0.0 (exe:CompileFail-exe) (first run) | ||
Configuring library 'failing' for CompileFail-0.1.0.0.. | ||
Preprocessing library 'failing' for CompileFail-0.1.0.0.. | ||
Building library 'failing' for CompileFail-0.1.0.0.. | ||
cabal: Failed to build CompileFail-0.1.0.0 because it depends on CompileFail-0.1.0.0 which itself failed to build. | ||
Failed to build CompileFail-0.1.0.0-inplace-failing. |
38 changes: 38 additions & 0 deletions
38
cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/compile-fail.test.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,38 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
import Test.Cabal.Prelude | ||
import Test.Cabal.DecodeShowBuildInfo | ||
import Test.Cabal.Plan | ||
import Control.Monad.Trans.Reader | ||
|
||
main = cabalTest $ do | ||
-- Leaf component fails to compile, should still dump | ||
-- build info for both components. | ||
fails $ runShowBuildInfo ["test:CompileFail-test"] | ||
withPlan $ do | ||
-- Lib has to be built, thus info is dumped | ||
assertComponent "CompileFail" mainLib | ||
defCompAssertion | ||
{ modules = ["MyLib"] | ||
, sourceDirs = ["src"] | ||
} | ||
|
||
-- Build Info is still dumped, although compilation failed | ||
assertComponent "CompileFail" (test "CompileFail-test") | ||
defCompAssertion | ||
{ sourceFiles = ["Main.hs"] | ||
, sourceDirs = ["test"] | ||
} | ||
|
||
fails $ runShowBuildInfo ["exe:CompileFail-exe"] | ||
withPlan $ do | ||
-- Internal Lib has to be built, thus info is dumped | ||
assertComponent "CompileFail" (lib "failing") | ||
defCompAssertion | ||
{ modules = ["MyLib2"] | ||
, sourceDirs = ["src"] | ||
} | ||
-- However, since the internal lib failed to compile | ||
-- we can not have executable build information. | ||
Just plan <- fmap testPlan ask | ||
let fp = buildInfoFile plan "CompileFail" (exe "CompileFail-exe") | ||
shouldNotExist fp |
4 changes: 4 additions & 0 deletions
4
cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/src/MyLib.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,4 @@ | ||
module MyLib (someFunc) where | ||
|
||
someFunc :: IO () | ||
someFunc = putStrLn "someFunc" |
6 changes: 6 additions & 0 deletions
6
cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/src/MyLib2.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 @@ | ||
module MyLib2 (someFunc2) where | ||
|
||
someFunc2 :: IO () | ||
-- Intentional typo, should fail to compile | ||
someFunc2 = putStrn "someFunc" | ||
-- ^^------- missing 'L' |
6 changes: 6 additions & 0 deletions
6
cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/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 @@ | ||
module Main (main) where | ||
|
||
main :: IO () | ||
-- Intentional typo, should fail to compile | ||
main = putStrn "Test suite not yet implemented." | ||
-- ^^------- missing 'L' |
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