[commit: haddock] 2.17.3.1-spanfix, alexbiehl-patch-1, ghc-8.0, ghc-8.0-facebook, ghc-head, ghc-head1, haddock-quick, headdock-library-1.4.5, ie_avails, issue-303, issue-475, master, pr-filter-maps, pr/cabal-desc, travis, v2.17, v2.17.3, v2.18, wip-located-module-as, wip/D2418, wip/T11080-open-data-kinds, wip/T11430, wip/T12105, wip/T12105-2, wip/T12942, wip/T13163, wip/T14529, wip/T3384, wip/embelleshed-rdr, wip/new-tree-one-param, wip/rae, wip/remove-frames, wip/remove-frames1, wip/revert-ttg-2017-11-20, wip/ttg-2017-10-13, wip/ttg-2017-10-31, wip/ttg-2017-11-06, wip/ttg2-2017-11-10, wip/ttg3-2017-11-12, wip/ttg4-constraints-2017-11-13, wip/ttg6-unrevert-2017-11-22: Add GHC path to test runner configuration. (a380904)

git at git.haskell.org git at git.haskell.org
Tue Nov 28 11:36:54 UTC 2017


Repository : ssh://git@git.haskell.org/haddock

On branches: 2.17.3.1-spanfix,alexbiehl-patch-1,ghc-8.0,ghc-8.0-facebook,ghc-head,ghc-head1,haddock-quick,headdock-library-1.4.5,ie_avails,issue-303,issue-475,master,pr-filter-maps,pr/cabal-desc,travis,v2.17,v2.17.3,v2.18,wip-located-module-as,wip/D2418,wip/T11080-open-data-kinds,wip/T11430,wip/T12105,wip/T12105-2,wip/T12942,wip/T13163,wip/T14529,wip/T3384,wip/embelleshed-rdr,wip/new-tree-one-param,wip/rae,wip/remove-frames,wip/remove-frames1,wip/revert-ttg-2017-11-20,wip/ttg-2017-10-13,wip/ttg-2017-10-31,wip/ttg-2017-11-06,wip/ttg2-2017-11-10,wip/ttg3-2017-11-12,wip/ttg4-constraints-2017-11-13,wip/ttg6-unrevert-2017-11-22
Link       : http://git.haskell.org/haddock.git/commitdiff/a380904e39ea57e3907c0297b41eb546680b0d3a

>---------------------------------------------------------------

commit a380904e39ea57e3907c0297b41eb546680b0d3a
Author: Ɓukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Mon Aug 3 20:34:12 2015 +0200

    Add GHC path to test runner configuration.


>---------------------------------------------------------------

a380904e39ea57e3907c0297b41eb546680b0d3a
 html-test/run.hs | 68 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 40 insertions(+), 28 deletions(-)

diff --git a/html-test/run.hs b/html-test/run.hs
index 91e692a..61e0078 100755
--- a/html-test/run.hs
+++ b/html-test/run.hs
@@ -7,6 +7,9 @@ import Control.Monad
 
 import Data.Maybe
 
+import Distribution.Simple.Utils
+import Distribution.Verbosity
+
 import System.Console.GetOpt
 import System.Directory
 import System.Environment
@@ -31,33 +34,19 @@ resDir = rootDir </> "resources"
 
 data Config = Config
     { cfgHaddockPath :: FilePath
+    , cfgGhcPath :: FilePath
     , cfgFiles :: [FilePath]
     }
 
 
 main :: IO ()
 main = do
-    Config { .. } <- parseArgs =<< getArgs
+    Config { .. } <- loadConfig =<< getArgs
+    return ()
 
-    env <- Just . (:) ("haddock_datadir", resDir) <$> getEnvironment
 
-    handle <- runProcess' cfgHaddockPath $ processConfig
-        { pcEnv = env
-        , pcArgs = ["--version"]
-        }
-    waitForSuccess "Failed to run `haddock --version`" handle
-
-    handle <- runProcess' cfgHaddockPath $ processConfig
-        { pcEnv = env
-        , pcArgs = ["--ghc-version"]
-        }
-    waitForSuccess "Failed to run `haddock --ghc-version`" handle
-
-    putStrLn $ "Files to test: " ++ show cfgFiles
-
-
-parseArgs :: [String] -> IO Config
-parseArgs args = do
+loadConfig :: [String] -> IO Config
+loadConfig args = do
     let (flags, files, errors) = getOpt Permute options args
 
     when (not $ null errors) $ do
@@ -68,11 +57,35 @@ parseArgs args = do
         hPutStrLn stderr $ usageInfo "" options
         exitSuccess
 
+    env <- Just . (:) ("haddock_datadir", resDir) <$> getEnvironment
+
+    let cfgHaddockPath = flagsHaddockPath flags
+
+    printVersions env cfgHaddockPath
+
     cfgFiles <- processFileArgs files
-    let cfgHaddockPath = haddockPath flags
+    cfgGhcPath <- init <$> rawSystemStdout normal cfgHaddockPath
+        ["--print-ghc-path"]
 
+    putStrLn $ "Files to test: " ++ show cfgFiles
     return $ Config { .. }
 
+
+printVersions :: Maybe [(String, String)] -> FilePath -> IO ()
+printVersions env haddockPath = do
+    handle <- runProcess' haddockPath $ processConfig
+        { pcEnv = env
+        , pcArgs = ["--version"]
+        }
+    waitForSuccess "Failed to run `haddock --version`" handle
+
+    handle <- runProcess' haddockPath $ processConfig
+        { pcEnv = env
+        , pcArgs = ["--ghc-version"]
+        }
+    waitForSuccess "Failed to run `haddock --ghc-version`" handle
+
+
 processFileArgs :: [String] -> IO [FilePath]
 processFileArgs [] = filter isSourceFile <$> getDirectoryContents srcDir
 processFileArgs args = pure $ map processFileArg args
@@ -103,14 +116,13 @@ options =
     ]
 
 
-haddockPath :: [Flag] -> FilePath
-haddockPath flags = case mlast [ path | FlagHaddockPath path <- flags ] of
-    Just path -> path
-    Nothing -> rootDir </> "dist" </> "build" </> "haddock" </> "haddock"
-
-
-mlast :: [a] -> Maybe a
-mlast = listToMaybe . reverse
+flagsHaddockPath :: [Flag] -> FilePath
+flagsHaddockPath flags =
+    case mlast [ path | FlagHaddockPath path <- flags ] of
+        Just path -> path
+        Nothing -> rootDir </> "dist" </> "build" </> "haddock" </> "haddock"
+  where
+    mlast = listToMaybe . reverse
 
 
 data ProcessConfig = ProcessConfig



More information about the ghc-commits mailing list