diff --git a/cabal-install/Distribution/Client/CmdHaddock.hs b/cabal-install/Distribution/Client/CmdHaddock.hs index 0dd22bec77830de2aa95b2ee3b2ba2657e8c3b5b..0ed1aca2a200379d67f445edc76ec02c60f21b84 100644 --- a/cabal-install/Distribution/Client/CmdHaddock.hs +++ b/cabal-install/Distribution/Client/CmdHaddock.hs @@ -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 diff --git a/cabal-install/Distribution/Client/ProjectOrchestration.hs b/cabal-install/Distribution/Client/ProjectOrchestration.hs index 9e75c9ae8f6a3862331d257fe53623fe9765b731..5c35118ecd02e1f9a6c8994e9f0d0f6f993f3357 100644 --- a/cabal-install/Distribution/Client/ProjectOrchestration.hs +++ b/cabal-install/Distribution/Client/ProjectOrchestration.hs @@ -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 @@ -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 @@ -1030,6 +1030,7 @@ dieOnBuildFailures verbosity currentCommand plan buildOutcomes ] dieIfNotHaddockFailure + | currentCommand == HaddockCommand = die' | all isHaddockFailure failuresClassification = warn | otherwise = die' where diff --git a/cabal-testsuite/PackageTests/NewHaddock/Fails/Example.hs b/cabal-testsuite/PackageTests/NewHaddock/Fails/Example.hs new file mode 100644 index 0000000000000000000000000000000000000000..76287b43f72e789d9784c034f5e2ab0063798e52 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewHaddock/Fails/Example.hs @@ -0,0 +1,6 @@ +module Example where + +import Prelude + +example :: Int +example = False diff --git a/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.out b/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.out new file mode 100644 index 0000000000000000000000000000000000000000..cbfc470cbba6e6e4426f13be65f3595dd3273634 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.out @@ -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. diff --git a/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.project b/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.project new file mode 100644 index 0000000000000000000000000000000000000000..5356e76f67c76ea1cf221ce38a73edef1002225e --- /dev/null +++ b/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.project @@ -0,0 +1 @@ +packages: . \ No newline at end of file diff --git a/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.test.hs b/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..e872b3164598fa2933161fce9127dd4e91c66b31 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.test.hs @@ -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"] diff --git a/cabal-testsuite/PackageTests/NewHaddock/Fails/example.cabal b/cabal-testsuite/PackageTests/NewHaddock/Fails/example.cabal new file mode 100644 index 0000000000000000000000000000000000000000..5096de78b5daf2c99c523261a71ee7a10ac0fa50 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewHaddock/Fails/example.cabal @@ -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