Skip to content

Commit

Permalink
Add failing test case for cabal build --enable-build-info
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed May 8, 2024
1 parent 3395fa1 commit 211d613
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/ShowBuildInfo/WithProject/Lib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Lib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cabal-version: 3.0
name: WithProject
version: 0.1.0.0
build-type: Simple

common warnings
ghc-options: -Wall

library
import: warnings
exposed-modules: Lib
build-depends: base
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: ./

package WithProject
ghc-options: -haddock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# cabal build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- WithProject-0.1.0.0 (lib) (first run)
Configuring library for WithProject-0.1.0.0...
Preprocessing library for WithProject-0.1.0.0...
Building library for WithProject-0.1.0.0...
# show-build-info WithProject lib
{"cabal-lib-version":"<CABALVER>","compiler":{"flavour":"ghc","compiler-id":"ghc-<GHCVER>","path":"<GHCPATH>"},"components":[{"type":"lib","name":"lib","unit-id":"WithProject-0.1.0.0-inplace","compiler-args":["-fbuilding-cabal-package","-O","-outputdir","with-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build","-odir","with-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build","-hidir","with-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build","-stubdir","with-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build","-i","-i.","-iwith-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build","-iwith-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build/autogen","-iwith-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build/global-autogen","-Iwith-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build/autogen","-Iwith-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build/global-autogen","-Iwith-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build","-optP-include","-optPwith-project.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/WithProject-0.1.0.0/build/autogen/cabal_macros.h","-this-unit-id","WithProject-0.1.0.0-inplace","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","<ROOT>/with-project.dist/home/.cabal/store/ghc-<GHCVER>/package.db","-package-db","<ROOT>/with-project.dist/work/./dist/packagedb/ghc-<GHCVER>","-package-id","<PACKAGEDEP>","-XHaskell2010","-Wall"],"modules":["Lib"],"src-files":[],"hs-src-dirs":["."],"src-dir":"<ROOT>/","cabal-file":"WithProject.cabal"}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{-# LANGUAGE OverloadedStrings #-}
import Test.Cabal.Prelude
import Test.Cabal.DecodeShowBuildInfo

main = cabalTest $ do
runShowBuildInfo ["lib:WithProject"]
withPlan $ do
recordBuildInfo "WithProject" mainLib
assertComponent "WithProject" mainLib defCompAssertion
{ compilerArgsPred = ("-Wall" `elem`) -- added by 'WithProject.cabal'
, modules = ["Lib"]
, sourceDirs = ["."]
}

-- See #9927
assertComponent "WithProject" mainLib defCompAssertion
{ compilerArgsPred = ("-haddock" `notElem`) -- added by 'cabal.project', but not present
, modules = ["Lib"]
, sourceDirs = ["."]
}

0 comments on commit 211d613

Please sign in to comment.