Skip to content

Commit

Permalink
Merge pull request #6137 from haskell/issue-5977
Browse files Browse the repository at this point in the history
Issue 5977

(cherry picked from commit 0d2d9ca)
  • Loading branch information
phadej authored and 23Skidoo committed Aug 27, 2019
1 parent 1bb19f4 commit d4d224e
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cabal-install/Distribution/Client/CmdHaddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ haddockAction :: (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFl
haddockAction (configFlags, configExFlags, installFlags, haddockFlags, testFlags)
targetStrings globalFlags = do

baseCtx <- establishProjectBaseContext verbosity cliConfig OtherCommand
baseCtx <- establishProjectBaseContext verbosity cliConfig HaddockCommand

targetSelectors <- either (reportTargetSelectorProblems verbosity) return
=<< readTargetSelectors (localPackages baseCtx) Nothing targetStrings
Expand Down
5 changes: 3 additions & 2 deletions cabal-install/Distribution/Client/ProjectOrchestration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ import System.Posix.Signals (sigKILL, sigSEGV)

-- | Tracks what command is being executed, because we need to hide this somewhere
-- for cases that need special handling (usually for error reporting).
data CurrentCommand = InstallCommand | OtherCommand
data CurrentCommand = InstallCommand | HaddockCommand | OtherCommand
deriving (Show, Eq)

-- | This holds the context of a project prior to solving: the content of the
Expand Down Expand Up @@ -431,7 +431,7 @@ runProjectPostBuildPhase verbosity

-- Finally if there were any build failures then report them and throw
-- an exception to terminate the program
dieOnBuildFailures verbosity currentCommand elaboratedPlanToExecute buildOutcomes
dieOnBuildFailures verbosity currentCommand elaboratedPlanToExecute buildOutcomes

-- Note that it is a deliberate design choice that the 'buildTargets' is
-- not passed to phase 1, and the various bits of input config is not
Expand Down Expand Up @@ -1030,6 +1030,7 @@ dieOnBuildFailures verbosity currentCommand plan buildOutcomes
]

dieIfNotHaddockFailure
| currentCommand == HaddockCommand = die'
| all isHaddockFailure failuresClassification = warn
| otherwise = die'
where
Expand Down
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/NewHaddock/Fails/Example.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Example where

import Prelude

example :: Int
example = False
15 changes: 15 additions & 0 deletions cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# cabal v2-build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- example-1.0 (lib) (first run)
Configuring library for example-1.0..
Preprocessing library for example-1.0..
Building library for example-1.0..
# cabal v2-haddock
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- example-1.0 (lib) (first run)
Preprocessing library for example-1.0..
Running Haddock on library for example-1.0..
cabal: Failed to build documentation for example-1.0-inplace.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude
import System.Exit (ExitCode (..))

main = cabalTest $ do
fails $ cabal "v2-build" ["example"]
fails $ cabal "v2-haddock" ["example"]
9 changes: 9 additions & 0 deletions cabal-testsuite/PackageTests/NewHaddock/Fails/example.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: example
version: 1.0
build-type: Simple
cabal-version: >=1.10

library
default-language: Haskell2010
build-depends: base
exposed-modules: Example

0 comments on commit d4d224e

Please sign in to comment.