aboutsummaryrefslogtreecommitdiff
path: root/html-test
diff options
context:
space:
mode:
authorŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-08-04 17:07:58 +0200
committerŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-08-22 23:40:26 +0200
commit110599220155087d3c02a8a9a2f2d4834c666e47 (patch)
tree1b6f78f9597745b90ad4051848e1a6b223702c6f /html-test
parent11d74d7f84b7683501cbd0e88b62c98016c3a66d (diff)
Make Haddock standard output redirection be more configurable.
Diffstat (limited to 'html-test')
-rwxr-xr-xhtml-test/run.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/html-test/run.hs b/html-test/run.hs
index da414171..ace3c6a0 100755
--- a/html-test/run.hs
+++ b/html-test/run.hs
@@ -43,6 +43,7 @@ data Config = Config
, cfgGhcPath :: FilePath
, cfgFiles :: [FilePath]
, cfgHaddockArgs :: [String]
+ , cfgHaddockStdOut :: FilePath
, cfgEnv :: Environment
}
@@ -79,11 +80,11 @@ runHaddock :: Config -> IO ()
runHaddock (Config { .. }) = do
putStrLn "Running Haddock process..."
- devNull <- openFile "/dev/null" WriteMode
+ haddockStdOut <- openFile cfgHaddockStdOut WriteMode
handle <- runProcess' cfgHaddockPath $ processConfig
{ pcArgs = cfgHaddockArgs ++ cfgFiles
, pcEnv = Just $ cfgEnv
- , pcStdOut = Just $ devNull
+ , pcStdOut = Just $ haddockStdOut
}
waitForSuccess "Failed to run Haddock on specified test files" handle
@@ -127,6 +128,8 @@ loadConfig flags files = do
, baseDependencies cfgGhcPath
]
+ let cfgHaddockStdOut = fromMaybe "/dev/null" (flagsHaddockStdOut flags)
+
return $ Config { .. }
@@ -205,6 +208,7 @@ data Flag
= FlagHaddockPath FilePath
| FlagGhcPath FilePath
| FlagHaddockOptions String
+ | FlagHaddockStdOut FilePath
| FlagHelp
deriving Eq
@@ -217,6 +221,8 @@ options =
"path to GHC executable"
, Option [] ["haddock-options"] (ReqArg FlagHaddockOptions "OPTS")
"additional options to run Haddock with"
+ , Option [] ["haddock-stdout"] (ReqArg FlagHaddockStdOut "FILE")
+ "where to redirect Haddock output"
, Option ['h'] ["help"] (NoArg FlagHelp)
"display this help end exit"
]
@@ -235,6 +241,10 @@ flagsHaddockOptions flags = concat
[ words opts | FlagHaddockOptions opts <- flags ]
+flagsHaddockStdOut :: [Flag] -> Maybe FilePath
+flagsHaddockStdOut flags = mlast [ path | FlagHaddockStdOut path <- flags ]
+
+
type Environment = [(String, String)]
data ProcessConfig = ProcessConfig