From 4abf7d4979b5364da59f7412a3d7143aea26cf7e Mon Sep 17 00:00:00 2001
From: alexbiehl
Date: Fri, 2 Mar 2018 14:21:23 +0100
Subject: Enable running test suite with stock haddock and ghc using
```
$ cabal new-run -- html-test --haddock-path=$(which haddock) --ghc-path=$(which ghc)
```
---
haddock-test/src/Test/Haddock/Config.hs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
(limited to 'haddock-test/src/Test/Haddock')
diff --git a/haddock-test/src/Test/Haddock/Config.hs b/haddock-test/src/Test/Haddock/Config.hs
index 988636e4..2d16fa63 100644
--- a/haddock-test/src/Test/Haddock/Config.hs
+++ b/haddock-test/src/Test/Haddock/Config.hs
@@ -98,6 +98,7 @@ data Flag
= FlagHaddockPath FilePath
| FlagHaddockOptions String
| FlagHaddockStdOut FilePath
+ | FlagGhcPath FilePath
| FlagDiffTool FilePath
| FlagNoDiff
| FlagAccept
@@ -108,6 +109,8 @@ data Flag
flagsHaddockPath :: [Flag] -> Maybe FilePath
flagsHaddockPath flags = mlast [ path | FlagHaddockPath path <- flags ]
+flagsGhcPath :: [Flag] -> Maybe FilePath
+flagsGhcPath flags = mlast [ path | FlagGhcPath path <- flags ]
flagsHaddockOptions :: [Flag] -> [String]
flagsHaddockOptions flags = concat
@@ -130,6 +133,8 @@ options =
"additional options to run Haddock with"
, Option [] ["haddock-stdout"] (ReqArg FlagHaddockStdOut "FILE")
"where to redirect Haddock output"
+ , Option [] ["ghc-path"] (ReqArg FlagGhcPath "FILE")
+ "path ghc executable"
, Option [] ["diff-tool"] (ReqArg FlagDiffTool "PATH")
"diff tool to use when printing failed cases"
, Option ['a'] ["accept"] (NoArg FlagAccept)
@@ -178,8 +183,11 @@ loadConfig ccfg dcfg flags files = do
hPutStrLn stderr "Haddock executable not found"
exitFailure
- ghcPath <- init <$> rawSystemStdout normal cfgHaddockPath
- ["--print-ghc-path"]
+ ghcPath <- case flagsGhcPath flags of
+ Just fp -> return fp
+ Nothing -> init <$> rawSystemStdout normal
+ cfgHaddockPath
+ ["--print-ghc-path"]
printVersions cfgEnv cfgHaddockPath
--
cgit v1.2.3
From 58a73575d10cfe8f18c63e886e7cb53ccbcb65cd Mon Sep 17 00:00:00 2001
From: alexbiehl
Date: Fri, 2 Mar 2018 16:20:19 +0100
Subject: haddock-test: Be more explicit which packages to pass
We now pass `-hide-all-packages` to haddock when invoking the
testsuite. This ensures we don't accidentally pick up any dependencies
up through ghc.env files.
---
haddock-test/src/Test/Haddock/Config.hs | 13 +++++++++++--
html-test/ref/QuasiExpr.html | 10 ++++++++--
html-test/ref/TH.html | 6 +++++-
html-test/ref/Threaded_TH.html | 12 ++++++++++--
4 files changed, 34 insertions(+), 7 deletions(-)
(limited to 'haddock-test/src/Test/Haddock')
diff --git a/haddock-test/src/Test/Haddock/Config.hs b/haddock-test/src/Test/Haddock/Config.hs
index 2d16fa63..8b395b6c 100644
--- a/haddock-test/src/Test/Haddock/Config.hs
+++ b/haddock-test/src/Test/Haddock/Config.hs
@@ -197,6 +197,7 @@ loadConfig ccfg dcfg flags files = do
[ pure ["--no-warnings"]
, pure ["--odir=" ++ dcfgOutDir dcfg]
, pure ["--optghc=-w"]
+ , pure ["--optghc=-hide-all-packages"]
, pure $ flagsHaddockOptions flags
, baseDependencies ghcPath
]
@@ -244,13 +245,21 @@ baseDependencies ghcPath = do
#else
pkgIndex <- getInstalledPackages normal [GlobalPackageDB] cfg
#endif
- mapM (getDependency pkgIndex) ["base", "process", "ghc-prim"]
+ let
+ pkgs =
+ [ "array"
+ , "base"
+ , "ghc-prim"
+ , "process"
+ , "template-haskell"
+ ]
+ concat `fmap` mapM (getDependency pkgIndex) pkgs
where
getDependency pkgIndex name = case ifaces pkgIndex name of
[] -> do
hPutStrLn stderr $ "Couldn't find base test dependency: " ++ name
exitFailure
- (ifArg:_) -> pure ifArg
+ (ifArg:_) -> pure ["--optghc=-package" ++ name, ifArg]
ifaces pkgIndex name = do
pkg <- join $ snd <$> lookupPackageName pkgIndex (mkPackageName name)
iface <$> haddockInterfaces pkg <*> haddockHTMLs pkg
diff --git a/html-test/ref/QuasiExpr.html b/html-test/ref/QuasiExpr.html
index 66e31ec7..062ebb8d 100644
--- a/html-test/ref/QuasiExpr.html
+++ b/html-test/ref/QuasiExpr.html
@@ -301,7 +301,9 @@
>expr :: QuasiQuoter :: QuasiQuoter #
parseExprExp :: String -> Q Exp -> Q Exp #
decl :: Q [Dec] :: Q [Dec] #
forkTH :: Q Exp :: Q ExpforkTH :: Q Exp :: Q Exp #