diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/remove-outdated.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/remove-outdated.test.hs index f6bcdf047fe5eed54ff71df750e7efa7e38ca419..f2f0c4302fcaf10a2555009d21593b03745d681d 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/remove-outdated.test.hs +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/remove-outdated.test.hs @@ -3,7 +3,6 @@ import Test.Cabal.Prelude import Test.Cabal.DecodeShowBuildInfo import Test.Cabal.Plan import Control.Monad.Trans.Reader -import System.Directory main = cabalTest $ do runShowBuildInfo ["exe:A"] diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/CompileFail.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/CompileFail.cabal new file mode 100644 index 0000000000000000000000000000000000000000..0fd965fb985a5b4dda6d0b2e0861c9b92247229c --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/CompileFail.cabal @@ -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 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/app/Main.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/app/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..1a3121450a46fdf805d60081291400b3d37793c1 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/app/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import MyLib2 (someFunc2) + +main :: IO () +main = someFunc2 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/cabal.project b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/cabal.project new file mode 100644 index 0000000000000000000000000000000000000000..6f920794c8017bc226b410f45838d32325481c4f --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/cabal.project @@ -0,0 +1 @@ +packages: ./ diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/compile-fail.out b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/compile-fail.out new file mode 100644 index 0000000000000000000000000000000000000000..3c13bf35ea98f9179448daa99739c61a8a890a0c --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/compile-fail.out @@ -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. diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/compile-fail.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/compile-fail.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..fc1fba234d5afb1c79caada36b242cd46f7a46ed --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/compile-fail.test.hs @@ -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 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/src/MyLib.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/src/MyLib.hs new file mode 100644 index 0000000000000000000000000000000000000000..e657c4403f66f966da13d2027bf595d9673387f6 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/src/MyLib2.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/src/MyLib2.hs new file mode 100644 index 0000000000000000000000000000000000000000..9b620c62fcd2d699b74815d74392f06a74a34f1d --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/src/MyLib2.hs @@ -0,0 +1,6 @@ +module MyLib2 (someFunc2) where + +someFunc2 :: IO () +-- Intentional typo, should fail to compile +someFunc2 = putStrn "someFunc" +-- ^^------- missing 'L' diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/test/Main.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/test/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..bae4112fa9798d4fe5ab30080c53212bd4c54fcd --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/CompileFail/test/Main.hs @@ -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' diff --git a/cabal-testsuite/src/Test/Cabal/DecodeShowBuildInfo.hs b/cabal-testsuite/src/Test/Cabal/DecodeShowBuildInfo.hs index 47fbcc837953c7c5113a7033c233fc3a1a427942..02c1cb7e733fbc56bbf908f09735e4af7639d7ed 100644 --- a/cabal-testsuite/src/Test/Cabal/DecodeShowBuildInfo.hs +++ b/cabal-testsuite/src/Test/Cabal/DecodeShowBuildInfo.hs @@ -111,7 +111,7 @@ defCompAssertion = ComponentAssertion , modules = [] , sourceFiles = [] , sourceDirs = [] - , compType = mempty + , compType = "" } -- | Assert common build information, such as compiler location, compiler version