Skip to content

Commit f9dca8b

Browse files
committed
Don't output haddock stdout if verbosity is silent
1 parent 0dff8a6 commit f9dca8b

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

Cabal/Distribution/Simple/Haddock.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,9 @@ runHaddock verbosity tmpFileOpts comp platform haddockProg args
559559
renderArgs verbosity tmpFileOpts haddockVersion comp platform args $
560560
\(flags,result)-> do
561561

562-
runProgram verbosity haddockProg flags
562+
haddockOut <- getProgramOutput verbosity haddockProg flags
563+
unless (verbosity <= silent) $
564+
putStr haddockOut
563565

564566
notice verbosity $ "Documentation created: " ++ result
565567

cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.out

+9
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,13 @@ In order, the following will be built:
1212
- example-1.0 (lib) (first run)
1313
Preprocessing library for example-1.0..
1414
Running Haddock on library for example-1.0..
15+
cabal: '<HADDOCK>' exited with an error:
16+
17+
Example.hs:6:11: error:
18+
• Couldn't match expected type ‘Int’ with actual type ‘Bool’
19+
• In the expression: False
20+
In an equation for ‘example’: example = False
21+
|
22+
6 | example = False
23+
| ^^^^^
1524
cabal: Failed to build documentation for example-1.0-inplace.

cabal-testsuite/src/Test/Cabal/Monad.hs

+9-1
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ mkNormalizerEnv = do
411411
list_out <- liftIO $ readProcess (programPath ghc_pkg_program)
412412
["list", "--global", "--simple-output"] ""
413413
tmpDir <- liftIO $ getTemporaryDirectory
414+
haddock <- let prog = fromJust $ lookupKnownProgram "haddock" (testProgramDb env)
415+
in fmap (fst . fromJust) $ liftIO $
416+
programFindLocation prog (testVerbosity env)
417+
[ProgramSearchPathDefault]
414418
return NormalizerEnv {
415419
normalizerRoot
416420
= addTrailingPathSeparator (testSourceDir env),
@@ -423,8 +427,12 @@ mkNormalizerEnv = do
423427
normalizerKnownPackages
424428
= mapMaybe simpleParse (words list_out),
425429
normalizerPlatform
426-
= testPlatform env
430+
= testPlatform env,
431+
normalizerHaddock
432+
= haddock
427433
}
434+
where
435+
428436

429437
requireProgramM :: Program -> TestM ConfiguredProgram
430438
requireProgramM program = do

cabal-testsuite/src/Test/Cabal/OutputNormalizer.hs

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ normalizeOutput nenv =
3333
. resub (posixRegexEscape (normalizerGblTmpDir nenv) ++ "[a-z0-9.-]+") "<GBLTMPDIR>" -- note, after TMPDIR
3434
. resub (posixRegexEscape (normalizerRoot nenv)) "<ROOT>/"
3535
. resub (posixRegexEscape (normalizerTmpDir nenv)) "<TMPDIR>/"
36+
. resub (posixRegexEscape (normalizerHaddock nenv)) "<HADDOCK>"
3637
. appEndo (F.fold (map (Endo . packageIdRegex) (normalizerKnownPackages nenv)))
3738
-- Look for 0.1/installed-0d6uzW7Ubh1Fb4TB5oeQ3G
3839
-- These installed packages will vary depending on GHC version
@@ -66,6 +67,7 @@ data NormalizerEnv = NormalizerEnv
6667
, normalizerGhcVersion :: Version
6768
, normalizerKnownPackages :: [PackageId]
6869
, normalizerPlatform :: Platform
70+
, normalizerHaddock :: FilePath
6971
}
7072

7173
posixSpecialChars :: [Char]

0 commit comments

Comments
 (0)