@@ -14,6 +14,7 @@ import Distribution.System
14
14
import Text.Regex.Base
15
15
import Text.Regex.TDFA
16
16
import Data.Array ((!) )
17
+ import Data.List (isPrefixOf , isInfixOf )
17
18
18
19
import qualified Data.Foldable as F
19
20
@@ -62,18 +63,49 @@ normalizeOutput nenv =
62
63
else id )
63
64
-- hackage-security locks occur non-deterministically
64
65
. 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
65
70
where
66
71
packageIdRegex pid =
67
72
resub (posixRegexEscape (display pid) ++ " (-[A-Za-z0-9.-]+)?" )
68
73
(prettyShow (packageName pid) ++ " -<VERSION>" )
69
74
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
+
70
101
data NormalizerEnv = NormalizerEnv
71
102
{ normalizerRoot :: FilePath
72
103
, normalizerTmpDir :: FilePath
73
104
, normalizerGblTmpDir :: FilePath
74
105
, normalizerGhcVersion :: Version
75
106
, normalizerKnownPackages :: [PackageId ]
76
107
, normalizerPlatform :: Platform
108
+ , normalizerHaddock :: FilePath
77
109
}
78
110
79
111
posixSpecialChars :: [Char ]
0 commit comments