From ad82e40c858e313f8ff06eed058618fa1eaa8c19 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Thu, 13 Aug 2015 20:27:59 +0200 Subject: Create convenience wrappers to simplify in test entry points. --- haddock-test/src/Test/Haddock.hs | 4 ++++ haddock-test/src/Test/Haddock/Config.hs | 4 ++++ html-test/run.hs | 5 +---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/haddock-test/src/Test/Haddock.hs b/haddock-test/src/Test/Haddock.hs index 3c0c8d5f..de293eab 100644 --- a/haddock-test/src/Test/Haddock.hs +++ b/haddock-test/src/Test/Haddock.hs @@ -28,6 +28,10 @@ data CheckResult | Error String +runAndCheck :: Config c -> IO () +runAndCheck cfg = runHaddock cfg >> checkFiles cfg + + checkFiles :: Config c -> IO () checkFiles cfg@(Config { .. }) = do putStrLn "Testing output files..." diff --git a/haddock-test/src/Test/Haddock/Config.hs b/haddock-test/src/Test/Haddock/Config.hs index 3b6dfdeb..3068e52b 100644 --- a/haddock-test/src/Test/Haddock/Config.hs +++ b/haddock-test/src/Test/Haddock/Config.hs @@ -127,6 +127,10 @@ options = ] +parseArgs :: CheckConfig c -> DirConfig -> [String] -> IO (Config c) +parseArgs ccfg dcfg args = uncurry (loadConfig ccfg dcfg) =<< checkOpt args + + checkOpt :: [String] -> IO ([Flag], [String]) checkOpt args = do let (flags, files, errors) = getOpt Permute options args diff --git a/html-test/run.hs b/html-test/run.hs index 22a06ba3..2758bf56 100755 --- a/html-test/run.hs +++ b/html-test/run.hs @@ -23,10 +23,7 @@ dirConfig = defaultDirConfig $ takeDirectory __FILE__ main :: IO () -main = do - cfg <- uncurry (loadConfig checkConfig dirConfig) =<< checkOpt =<< getArgs - runHaddock cfg - checkFiles cfg +main = runAndCheck =<< parseArgs checkConfig dirConfig =<< getArgs -- *** OLD TEST RUNNER UTILITY FUNCTIONS *** -- cgit v1.2.3