From 17be133c363d161cff0a0e21968784afd2f7058a Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Tue, 4 Aug 2015 14:21:22 +0200 Subject: Refactor test runner and create stub functions. --- html-test/run.hs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'html-test') diff --git a/html-test/run.hs b/html-test/run.hs index 3a421be7..a9fe8bb7 100755 --- a/html-test/run.hs +++ b/html-test/run.hs @@ -48,15 +48,25 @@ data Config = Config main :: IO () main = do - cfg <- loadConfig =<< getArgs + cfg <- uncurry loadConfig =<< checkOpt =<< getArgs putStrLn $ show cfg + runHaddock cfg + checkOutput cfg -loadConfig :: [String] -> IO Config -loadConfig args = do +checkOutput :: Config -> IO () +checkOutput _ = return () -- TODO. + + +runHaddock :: Config -> IO () +runHaddock _ = return () -- TODO. + + +checkOpt :: [String] -> IO ([Flag], [String]) +checkOpt args = do let (flags, files, errors) = getOpt Permute options args - when (not $ null errors) $ do + unless (null errors) $ do hPutStr stderr $ concat errors exitFailure @@ -64,6 +74,11 @@ loadConfig args = do hPutStrLn stderr $ usageInfo "" options exitSuccess + return (flags, files) + + +loadConfig :: [Flag] -> [String] -> IO Config +loadConfig flags files = do env <- Just . (:) ("haddock_datadir", resDir) <$> getEnvironment cfgHaddockPath <- pure $ flip fromMaybe (flagsHaddockPath flags) $ -- cgit v1.2.3