[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: Make GHC path a test runner command-line argument. (c162d63)

git at git.haskell.org git at git.haskell.org
Tue Nov 28 11:36:45 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/c162d63f71839a02acb8017d7f15915d9cf7023d

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

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

    Make GHC path a test runner command-line argument.


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

c162d63f71839a02acb8017d7f15915d9cf7023d
 html-test/run.hs | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/html-test/run.hs b/html-test/run.hs
index 61e0078..829b570 100755
--- a/html-test/run.hs
+++ b/html-test/run.hs
@@ -59,15 +59,16 @@ loadConfig args = do
 
     env <- Just . (:) ("haddock_datadir", resDir) <$> getEnvironment
 
-    let cfgHaddockPath = flagsHaddockPath flags
+    cfgHaddockPath <- pure $ flip fromMaybe (flagsHaddockPath flags) $
+        rootDir </> "dist" </> "build" </> "haddock" </> "haddock"
 
     printVersions env cfgHaddockPath
 
+    cfgGhcPath <- flip fromMaybe (flagsGhcPath flags) <$>
+         init <$> rawSystemStdout normal cfgHaddockPath ["--print-ghc-path"]
+
     cfgFiles <- processFileArgs files
-    cfgGhcPath <- init <$> rawSystemStdout normal cfgHaddockPath
-        ["--print-ghc-path"]
 
-    putStrLn $ "Files to test: " ++ show cfgFiles
     return $ Config { .. }
 
 
@@ -103,6 +104,7 @@ isSourceFile path = takeExtension path `elem` [".hs", ".lhs"]
 
 data Flag
     = FlagHaddockPath FilePath
+    | FlagGhcPath FilePath
     | FlagHelp
     deriving Eq
 
@@ -111,18 +113,19 @@ options :: [OptDescr Flag]
 options =
     [ Option [] ["haddock-path"] (ReqArg FlagHaddockPath "FILE")
         "path to Haddock executable to exectue tests with"
+    , Option [] ["ghc-path"] (ReqArg FlagGhcPath "FILE")
+        "path to GHC executable"
     , Option ['h'] ["help"] (NoArg FlagHelp)
         "display this help end exit"
     ]
 
 
-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
+flagsHaddockPath :: [Flag] -> Maybe FilePath
+flagsHaddockPath flags = mlast [ path | FlagHaddockPath path <- flags ]
+
+
+flagsGhcPath :: [Flag] -> Maybe FilePath
+flagsGhcPath flags = mlast [ path | FlagGhcPath path <- flags ]
 
 
 data ProcessConfig = ProcessConfig
@@ -157,3 +160,7 @@ waitForSuccess msg handle = do
     unless (result == ExitSuccess) $ do
         hPutStrLn stderr $ msg
         exitFailure
+
+
+mlast :: [a] -> Maybe a
+mlast = listToMaybe . reverse



More information about the ghc-commits mailing list