diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal index 711f4dea636..4bd11d9b040 100644 --- a/Cabal/Cabal.cabal +++ b/Cabal/Cabal.cabal @@ -83,6 +83,7 @@ extra-source-files: tests/PackageTests/Haddock/CPP.hs tests/PackageTests/Haddock/Literate.lhs tests/PackageTests/Haddock/my.cabal + tests/PackageTests/Haddock/NoCPP.hs tests/PackageTests/Haddock/Simple.hs tests/PackageTests/OrderFlags/Foo.hs tests/PackageTests/OrderFlags/my.cabal diff --git a/Cabal/Distribution/Simple/Haddock.hs b/Cabal/Distribution/Simple/Haddock.hs index 79c7d050541..7e1b10a72b7 100644 --- a/Cabal/Distribution/Simple/Haddock.hs +++ b/Cabal/Distribution/Simple/Haddock.hs @@ -27,7 +27,7 @@ import Distribution.Package , PackageName(..), packageName ) import qualified Distribution.ModuleName as ModuleName import Distribution.PackageDescription as PD - ( PackageDescription(..), BuildInfo(..), allExtensions + ( PackageDescription(..), BuildInfo(..), usedExtensions , Library(..), hasLibs, Executable(..) , TestSuite(..), TestSuiteInterface(..) , Benchmark(..), BenchmarkInterface(..) ) @@ -365,7 +365,7 @@ getGhcCppOpts haddockVersion bi = ghcOptCppOptions = defines } where - needsCpp = EnableExtension CPP `elem` allExtensions bi + needsCpp = EnableExtension CPP `elem` usedExtensions bi defines = [haddockVersionMacro] haddockVersionMacro = "-D__HADDOCK_VERSION__=" ++ show (v1 * 1000 + v2 * 10 + v3) diff --git a/Cabal/tests/PackageTests/Haddock/Check.hs b/Cabal/tests/PackageTests/Haddock/Check.hs index cbfe522c078..0d41dd45156 100644 --- a/Cabal/tests/PackageTests/Haddock/Check.hs +++ b/Cabal/tests/PackageTests/Haddock/Check.hs @@ -26,7 +26,7 @@ suite ghcPath = TestCase $ do assertHaddockSucceeded hResult let docFiles = map (haddocksDir ) - ["CPP.html", "Literate.html", "Simple.html"] + ["CPP.html", "Literate.html", "NoCPP.html", "Simple.html"] mapM_ (assertFindInFile "For hiding needles.") docFiles assertFindInFile :: String -> FilePath -> Assertion diff --git a/Cabal/tests/PackageTests/Haddock/NoCPP.hs b/Cabal/tests/PackageTests/Haddock/NoCPP.hs new file mode 100644 index 00000000000..417f368b37c --- /dev/null +++ b/Cabal/tests/PackageTests/Haddock/NoCPP.hs @@ -0,0 +1,8 @@ +module NoCPP (Haystack) where + +-- | For hiding needles. +data Haystack = Haystack + +-- | Causes a build failure if the CPP language extension is enabled. +stringGap = "Foo\ +\Bar" diff --git a/Cabal/tests/PackageTests/Haddock/my.cabal b/Cabal/tests/PackageTests/Haddock/my.cabal index 63e9faa4a7c..176ced9b4de 100644 --- a/Cabal/tests/PackageTests/Haddock/my.cabal +++ b/Cabal/tests/PackageTests/Haddock/my.cabal @@ -11,6 +11,6 @@ description: Check that Cabal successfully invokes Haddock. Library - exposed-modules: CPP, Literate, Simple + exposed-modules: CPP, Literate, NoCPP, Simple other-extensions: CPP build-depends: base