@@ -14,6 +14,7 @@ import Distribution.System
1414import Text.Regex.Base
1515import Text.Regex.TDFA
1616import Data.Array ((!) )
17+ import Data.List (isPrefixOf , isInfixOf )
1718
1819import qualified Data.Foldable as F
1920
@@ -62,18 +63,49 @@ normalizeOutput nenv =
6263 else id )
6364 -- hackage-security locks occur non-deterministically
6465 . resub " (Released|Acquired|Waiting) .*hackage-security-lock\n " " "
66+ -- Substitute the haddock binary with <HADDOCK>
67+ -- Do this before the <GHCVER> substitution
68+ . resub (posixRegexEscape (normalizerHaddock nenv)) " <HADDOCK>"
69+ . removeErrors
6570 where
6671 packageIdRegex pid =
6772 resub (posixRegexEscape (display pid) ++ " (-[A-Za-z0-9.-]+)?" )
6873 (prettyShow (packageName pid) ++ " -<VERSION>" )
6974
75+ {- Given
76+ cabal: blah exited with an error:
77+ Example.hs:6:11: error:
78+ * Couldn't match expected type `Int' with actual type `Bool'
79+ * In the expression: False
80+ In an equation for `example': example = False
81+ |
82+ 6 | example = False
83+ | ^^^^^
84+ cabal: Failed to build documentation for example-1.0-inplace.
85+
86+ this will remove the error in between the first line with "exited with an error"
87+ and the closing "cabal:". Pretty nasty, but its needed to ignore errors from
88+ external programs whose output might change.
89+ -}
90+ removeErrors :: String -> String
91+ removeErrors s = unlines (go (lines s) False )
92+ where
93+ go [] _ = []
94+ go (x: xs) True
95+ | " cabal:" `isPrefixOf` x = x: (go xs False )
96+ | otherwise = go xs True
97+ go (x: xs) False
98+ | " exited with an error" `isInfixOf` x = x: (go xs True )
99+ | otherwise = x: (go xs False )
100+
70101data NormalizerEnv = NormalizerEnv
71102 { normalizerRoot :: FilePath
72103 , normalizerTmpDir :: FilePath
73104 , normalizerGblTmpDir :: FilePath
74105 , normalizerGhcVersion :: Version
75106 , normalizerKnownPackages :: [PackageId ]
76107 , normalizerPlatform :: Platform
108+ , normalizerHaddock :: FilePath
77109 }
78110
79111posixSpecialChars :: [Char ]
0 commit comments